/*
nonamexwapk::name::贴吧精品::version::1.0.0::nonamexwapkend
*/
'use strict';
game.import("extension", function(lib, game, ui, get, ai, _status) {
  return {
    name: "贴吧精品",
    editable: false,
    content: function(config, pack) {
      console.time(_status.extension);
      if (pack.changelog) {
        try {
          let a = 1;
          const b = 1;
          (() => a + b)();
        } catch (error) {
          if (!lib.config["extension_贴吧精品_compatibilityAlert"]) {
            game.saveconfig("extension_贴吧精品_compatibilityAlert", true);
            alert("贴吧精品与你的设备不兼容", "贴吧精品");
          }
          pack.changelog = `<span style="font-weight:bold;">贴吧精品与你的设备不兼容，因此导入被终止了。</span><br>` + pack.changelog;
          return;
        }
        game.showExtensionChangeLog(pack.changelog);
      }
      if (config.simple_name === 'hide') {
        get.slimName = function(str) {

          var str2 = lib.translate[str];
          if (lib.translate[str + '_ab']) str2 = lib.translate[str + '_ab'];
          if (!str2) return '';
          var str3 = str2.replace(/^(\s|[☆A-Z])*/, "");
          if (str3 != "") {
            str2 = str3;
          }
          if (str2.startsWith('手杀')) {
            str2 = str2.slice(2);
          }
          return get.verticalStr(str2, true);
        };
      }
      lib.config.all.characters.push('race3d8', 'person3d8');

      console.timeEnd(_status.extension);
    },
    precontent: function(config) {
      if (!config.enable) {
        return;
      }
      console.time(_status.extension + 'pre');
      if (config.debug) {
        lib.config.characters = ["race3d8", "person3d8"];
      }
      game.import('character', function() { // SK
        var race3d8 = {
          name: 'race3d8',
          connect: true,
          characterSort: {
            race3d8: {
              race_5: ['3d8_caoxiu', '3d8_wuzhi', '3d8_jikang', '3d8sp_dongyun', '3d8_xujing', '3d8_zhugezhan', '3d8_buzhi', '3d8_sunhao', '3d8_zhanglu', '3d8_yuantanyuanshang'],
              race_6: ['3d8_caomao', '3d8_wanglang', '3d8_xinxianying', '3d8_huojun', '3d8_huangquan', '3d8_xianglang', '3d8_sunliang', '3d8_lvfan', '3d8_lukai', '3d8_chendeng', '3d8_caojie'],
              race_7: ['3d8_chentai', '3d8_liuye', '3d8_wuban', '3d8_baosanniang', '3d8_kanze', '3d8_sunhuan', '3d8_liuqi', '3d8_zhangxiu', '3d8_handang'],
              race_8: ['3d8_guoxun', '3d8_lvbu', '3d8_simashi', '3d8_jiangji', '3d8_dengzhi', '3d8_wangkanglvkai', '3d8_sunjun', '3d8_panshu', '3d8_mengda'],
              race_9: ['3d8_caoshuang', '3d8_dongzhao', '3d8_donghe', '3d8_zongyu', '3d8_sunshao', '3d8_puyangxing', '3d8_zhangmiao', '3d8_chenggongying', '3d8_shen_zhenji', '3d8_shen_guojia'],
              race_10: ['3d8_zhaoang', '3d8_xuelingyun', '3d8_luoxian', '3d8_chenshou', '3d8_zhangti', '3d8_zhugejing', '3d8_huangzu', '3d8_liuhong'],
              race_11: ['3d8_wangling', '3d8_xiahouxuan', '3d8_qiaozhou', '3d8_luotong', '3d8_luji', '3d8_zhangzhongjing', '3d8_liuchong', '3d8_hanfu'],
              race_12: ['3d8_qianzhao', '3d8_lougui', '3d8_liaoli', '3d8_huji', '3d8_sunhe', '3d8_zhouchu', '3d8_zhangkai', '3d8_kebineng'],
              race_misc: ['3d8_sunli', '3d8_weiguan', '3d8_taohuang', '3d8_leitongwulan', '3d8_shen_machao'],
            },
          },
          character: {
            "3d8_caoxiu": ["male", "wei", 4, ["xiansheng3d8"],
              []
            ],
            "3d8_wuzhi": ["male", "wei", 3, ["lingyong3d8", "xuxiao3d8"],
              []
            ],
            "3d8_jikang": ["male", "wei", 3, ["qingxian3d8", "juexiang3d8"],
              []
            ],
            "3d8sp_dongyun": ["male", "shu", 3, ["biwei3d8", "juanlue3d8"],
              []
            ],
            "3d8_xujing": ["male", "shu", 3, ["xuyu3d8", "shijian3d8"],
              []
            ],
            "3d8_zhugezhan": ["male", "shu", 4, ["ziwen3d8"],
              []
            ],
            "3d8_buzhi": ["male", "wu", 3, ["weizhong3d8", "jingjing3d8"],
              []
            ],
            "3d8_sunhao": ["male", "wu", 4, ["jiuyan3d8", "zongying3d8", "jichi3d8"],
              ["zhu"]
            ],
            "3d8_zhanglu": ["male", "qun", 3, ["mijiao3d8", "yishe3d8"],
              []
            ],
            "3d8_yuantanyuanshang": ["male", "qun", 4, ["dikai3d8", "zhengsi3d8"],
              []
            ],

            "3d8_caomao": ["male", "wei", 3, ["taisi3d8", "quche3d8", "qianlong3d8"],
              ["zhu"]
            ],
            "3d8_wanglang": ["male", "wei", 3, ["lunzhan3d8", "boya3d8"],
              []
            ],
            "3d8_xinxianying": ["female", "wei", 3, ["dongcha3d8", "zhijie3d8"],
              []
            ],
            "3d8_huojun": ["male", "shu", 4, ["gushou3d8"],
              []
            ],
            "3d8_huangquan": ["male", "shu", 4, ["tandi3d8"],
              []
            ],
            "3d8_xianglang": ["male", "shu", 3, ["qiahua3d8", "fusi3d8", "tuoji3d8"],
              []
            ],
            "3d8_sunliang": ["male", "wu", 3, ["diedang3d8", "anliu3d8"],
              ["zhu"]
            ],
            "3d8_lvfan": ["male", "wu", 4, ["kewu3d8"],
              []
            ],
            "3d8_lukai": ["male", "wu", 3, ["jingxuan3d8", "kenjian3d8"],
              []
            ],
            "3d8_chendeng": ["male", "qun", 3, ["jianni3d8", "yiluan3d8"],
              []
            ],
            "3d8_caojie": ["female", "qun", 3, ["tianzuo3d8", "dixi3d8"],
              []
            ],

            "3d8_chentai": ["male", "wei", 4, ["jieye3d8"],
              []
            ],
            "3d8_liuye": ["male", "wei", 3, ["chashi3d8", "qice3d8"],
              []
            ],
            "3d8_wuban": ["male", "shu", 4, ["youzhen3d8"],
              []
            ],
            "3d8_baosanniang": ["female", "shu", 3, ["zhilian3d8", "jijian3d8"],
              []
            ],
            "3d8_kanze": ["male", "wu", 3, ["huikuo3d8", "linrun3d8"],
              []
            ],
            "3d8_sunhuan": ["male", "wu", 4, ["renxian3d8"],
              []
            ],
            "3d8_liuqi": ["male", "qun", 3, ["chouti3d8", "zonghuo3d8"],
              []
            ],
            "3d8_zhangxiu": ["male", "qun", 4, ["baiyou3d8", "fandi3d8"],
              []
            ],
            "3d8_handang": ["male", "wu", 4, ["jiefan3d8", "gongqi3d8"],
              []
            ],

            "3d8_guoxun": ["male", "shu", 4, ["qianfu3d8", "zhuci3d8"],
              []
            ],
            "3d8_lvbu": ["male", "qun", 4, ["pimi3d8", "baonu3d8"],
              []
            ],
            "3d8_simashi": ["male", "wei", 4, ["tongshe3d8"],
              []
            ],
            "3d8_jiangji": ["male", "wei", 3, ["shenshi3d8", "bigong3d8"],
              []
            ],
            "3d8_dengzhi": ["male", "shu", 3, ["ximeng3d8", "shiduan3d8"],
              []
            ],
            "3d8_wangkanglvkai": ["male", "shu", 4, ["bingjian3d8"],
              []
            ],
            "3d8_sunjun": ["male", "wu", 4, ["shanquan3d8", "xiongyi3d8"],
              []
            ],
            "3d8_panshu": ["female", "wu", 3, ["dujuan3d8", "tuchou3d8"],
              []
            ],
            "3d8_mengda": ["male", "qun", 4, ["humou3d8", "xuanshi3d8"],
              []
            ],

            "3d8_caoshuang": ["male", "wei", 4, ["zhuanshe3d8", "weiqiu3d8"],
              ["die_audio"],
              []
            ],
            "3d8_dongzhao": ["male", "wei", 3, ["xianshi3d8", "zaowang3d8"],
              []
            ],
            "3d8_donghe": ["male", "shu", 3, ["shijiand3d8", "zhengfeng3d8"],
              []
            ],
            "3d8_zongyu": ["male", "shu", "3/4", ["tanli3d8", "dengjing3d8"],
              []
            ],
            "3d8_sunshao": ["male", "wu", 4, ["wenbing3d8"],
              ["die_audio"],
              []
            ],
            "3d8_puyangxing": ["male", "wu", 3, ["sili3d8", "xintu3d8"],
              []
            ],
            "3d8_zhangmiao": ["male", "qun", 4, ["xiaxing3d8"],
              []
            ],
            "3d8_chenggongying": ["male", "qun", 3, ["pingxi3d8", "wangzhi3d8"],
              []
            ],
            "3d8_shen_zhenji": ["female", "shen", 3, ["miaoxing3d8", "fushi3d8"],
              []
            ],
            "3d8_shen_guojia": ["male", "shen", 3, ["fujv13d8", "fujv23d8", "fujv33d8"],
              []
            ],

            "3d8_zhaoang": ["male", "wei", 4, ["fenji3d8"],
              []
            ],
            "3d8_xuelingyun": ["female", "wei", 3, ["lianer3d8", "anzhi3d8"],
              []
            ],
            "3d8_luoxian": ["male", "shu", 4, ["shilie3d8"],
              []
            ],
            "3d8_chenshou": ["male", "shu", 3, ["zhishuc3d8", "xunlu3d8"],
              []
            ],
            "3d8_zhangti": ["male", "wu", 3, ["nishi3d8", "fujiang3d8"],
              []
            ],
            "3d8_zhugejing": ["male", "wu", 4, ["sansi3d8", "jiezhong3d8"],
              []
            ],
            "3d8_huangzu": ["male", "qun", 4, ["tunshou3d8"],
              []
            ],
            "3d8_liuhong": ["male", "qun", 4, ["shixing3d8", "danggu3d8"],
              []
            ],

            "3d8_wangling": ["male", "wei", 4, ["zhangchuan3d8", "xingbian3d8"],
              []
            ],
            "3d8_xiahouxuan": ["male", "wei", 3, ["langhuai3d8", "xuanlun3d8"],
              []
            ],
            "3d8_qiaozhou": ["male", "shu", 3, ["chouguo3d8", "jianxiang3d8"],
              []
            ],
            "3d8_zhangzhongjing": ["male", "qun", 3, ["quhan3d8", "changtang3d8"],
              []
            ],
            "3d8_luotong": ["male", "wu", 3, ["huili3d8", "zhishu3d8"],
              []
            ],
            "3d8_luji": ["male", "wu", 3, ["bianwang3d8", "kuangnan3d8"],
              ["die_audio"],
              []
            ],
            "3d8_liuchong": ["male", "qun", 4, ["jinggou3d8", "moyan3d8"],
              []
            ],
            "3d8_hanfu": ["male", "qun", 5, ["yijue3d8"],
              []
            ],

            "3d8_qianzhao": ["male", "wei", 4, ["yuanzhen3d8", "zhirong3d8"],
              []
            ],
            "3d8_lougui": ["male", "wei", 3, ["ningbei3d8", "jince3d8"],
              []
            ],
            "3d8_liaoli": ["male", "shu", 3, ["fenlun3d8", "qicai3d8"],
              []
            ],
            "3d8_huji": ["male", "shu", 4, ["jianjun3d8"],
              []
            ],
            "3d8_sunhe": ["male", "wu", 3, ["mingye3d8", "danghu3d8"],
              []
            ],
            "3d8_zhouchu": ["male", "wu", 5, ["xiaheng3d8"],
              []
            ],
            "3d8_zhangkai": ["male", "qun", "3/4", ["jiexing3d8", "bailei3d8"],
              []
            ],
            "3d8_kebineng": ["male", "qun", 4, ["xiaoxing3d8", "langzhi3d8", "fuyi3d8"],
              ["zhu"]
            ],

            "3d8_sunli": ["male", "wei", 4, ["leili3d8", "fengxing3d8"],
              []
            ],
            "3d8_weiguan": ["male", "wei", 3, ["dijiang3d8", "yuwang3d8"],
              []
            ],
            "3d8_taohuang": ["male", "wu", "3/4", ["zhiduan3d8", "weizheng3d8"],
              []
            ],
            "3d8_leitongwulan": ["male", "shu", 4, ["haolie3d8"],
              []
            ],
            "3d8_shen_machao": ["male", "shen", 4, ["hengxiao3d8", "zongchi3d8"],
              []
            ],
          },
          characterTitle: {
            "3d8_caoxiu": "RP集散中心",
            "3d8_wuzhi": "沸治·克里夫",
            "3d8_jikang": "GODLASTER",
            "3d8_dongyun": "会乱武的袁绍",
            "3d8_xujing": "沸治·克里夫",
            "3d8_zhugezhan": "流水席",
            "3d8_buzhi": "6464543",
            "3d8_sunhao": "数据流突袭者",
            "3d8_zhanglu": "低调de洛沫",
            "3d8_yuantanyuanshang": "キ狐fツx狸ネ",

            "3d8_caomao": "Rocxu",
            "3d8_wanglang": "折纸de飞机",
            "3d8_xinxianying": "好孩子系我",
            "3d8_huangquan": "rocxu",
            "3d8_xianglang": "会乱武的袁绍",
            "3d8_sunliang": "空照",
            "3d8_lvfan": "起个ID好烦",
            "3d8_lukai": "刘井闪",
            "3d8_chendeng": "隔夜星河",
            "3d8_caojie": "谜样小红",

            "3d8_chentai": "勤奋的膜法师",
            "3d8_liuye": "好孩子系我",
            "3d8_wuban": "龙哥头屑",
            "3d8_baosanniang": "会乱武的袁绍",
            "3d8_kanze": "搁浅的和锦",
            "3d8_sunhuan": "龙哥头屑",
            "3d8_liuqi": "zengzouyu",
            "3d8_zhangxiu": "无限连的陆伯言",
            "3d8_handang": "好孩子系我",

            "3d8_guoxun": "笑谈香芋",
            "3d8_lvbu": "好孩子系我",
            "3d8_simashi": "妖怪",
            "3d8_jiangji": "RP",
            "3d8_dengzhi": "扬林",
            "3d8_wangkanglvkai": "扬林",
            "3d8_sunjun": "RP",
            "3d8_panshu": "拉普拉斯",
            "3d8_mengda": "LR",

            "3d8_caoshuang": "辰木",
            "3d8_dongzhao": "GENTOVA",
            "3d8_donghe": "jcj熊",
            "3d8_zongyu": "馴良",
            "3d8_sunshao": "菲姆",
            "3d8_puyangxing": "龙哥头屑",
            "3d8_zhangmiao": "厨房给好友",
            "3d8_chenggongying": "拉普拉斯",
            "3d8_shen_zhenji": "懿肆琬兮",
            "3d8_shen_guojia": "云横&冥狐",

            "3d8_zhaoang": "君腾天下",
            "3d8_xuelingyun": "GENTOVA07",
            "3d8_luoxian": "绝代倾国倾城貌",
            "3d8_chenshou": "是不定时",
            "3d8_zhangti": "晨曦千载",
            "3d8_zhugejing": "绝代倾国倾城貌",
            "3d8_huangzu": "我12345咧个去",
            "3d8_liuhong": "拉普拉斯",

            "3d8_wangling": "拉普拉斯",
            "3d8_xiahouxuan": "好孩子系我",
            "3d8_qiaozhou": "龙哥头屑",
            "3d8_luotong": "好孩子系我",
            "3d8_luji": "扬林0602",
            "3d8_zhangzhongjing": "克己盖饭",
            "3d8_liuchong": "扬林0602",
            "3d8_hanfu": "好孩子系我",

            "3d8_qianzhao": "林己",
            "3d8_lougui": "盛夏的方程式X",
            "3d8_liaoli": "理亚",
            "3d8_huji": "梦阑歌",
            "3d8_sunhe": "再見末日基因",
            "3d8_zhouchu": "志文",
            "3d8_zhangkai": "轻帆过海",
            "3d8_kebineng": "晨星",

            "3d8_weiguan": "k1287420416",
            "3d8_taohuang": "心绮楼的秦心酱",
            "3d8_leitongwulan": "好孩子系我",
            "3d8_shen_machao": "边良企丶我爱杀",

          },
          skill: {
            xiansheng3d8: {
              trigger: {
                global: "phaseUseBegin",
              },
              frequent: true,
              popup: false,
              filter: function(event, player) {
                if (event.player == player) return false;
                if (!lib.filter.targetEnabled2({
                    name: 'sha'
                  }, player, event.player)) return false;
                return true;
              },
              check: function(event, player) {
                var current = _status.currentPhase;
                var enemy = 0;
                current = current.next;
                while (current != player) {
                  if (get.effect(current, {
                      name: 'sha'
                    }, player) > 0 && lib.filter.targetEnabled2({
                      name: 'sha'
                    }, player, current) && current.hp < _status.currentPhase.hp && current.countCards("h") < _status.currentPhase.countCards("h")) enemy += 1;
                  current = current.next;
                }
                return enemy < player.countCards('h', 'sha') && (player.countCards('h', 'sha') > 0 || player.getEquip("zhangba") == 'zhangba') && get.effect(event.player, {
                  name: 'sha'
                }, player) > 0;
              },
              content: function() {
                player.chooseToUse({
                  name: 'sha'
                }, trigger.player, '是否对' + get.translation(trigger.player) + '使用一张杀？');
              },
              ai: {
                expose: 0.5,
                threaten: 1.5,
              },
              group: ["xiansheng3d8_sha", "xiansheng3d8_damage", "xiansheng3d8_miss"],
              subSkill: {
                sha: {
                  audio: "taoxi",
                  forced: true,
                  trigger: {
                    player: "useCard",
                  },
                  filter: function(event, player) {
                    return event.card && event.card.name == 'sha' && event.parent.parent.name == 'xiansheng3d8';
                  },
                  content: function() {
                    player.storage.xiansheng3d8_sha = 1;
                  },
                  sub: true,
                },
                damage: {
                  trigger: {
                    source: "damageEnd",
                  },
                  filter: function(event, player) {
                    return event.card && event.card.name == 'sha' && player.storage.xiansheng3d8_sha == 1;
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    player.storage.xiansheng3d8_sha = 0;
                    trigger.player.addTempSkill('xiansheng3d8_block');
                  },
                  sub: true,
                },
                miss: {
                  trigger: {
                    player: "shaMiss",
                  },
                  filter: function(event, player) {
                    return event.card && event.card.name == 'sha' && player.storage.xiansheng3d8_sha == 1;
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    player.storage.xiansheng3d8_sha = 2;
                    trigger.target.addTempSkill('xiansheng3d8_dis');
                  },
                  sub: true,
                },
                block: {
                  mod: {
                    cardEnabled: function(card) {
                      if (card.name == 'sha') return false;
                    },
                  },
                },
                dis: {
                  sub: true,
                  onremove: true,
                  mod: {
                    globalFrom: function(from, to, distance) {
                      if (to.storage.xiansheng3d8_sha == 2) return -Infinity;
                    },
                  },
                },
              },
              ai: {
                expose: 0.2,
                threaten: 1.3,
                effect: {
                  player: function(card, player, target, current) {
                    if (!player.isPhaseUsing()) return;
                    if (card.name != 'sha' || player.countCards("h", {
                        name: "sha"
                      }) != 1) return;
                    return 'zeroplayertarget';
                  },
                },
              },
            },

            lingyong3d8: {
              group: ["lingyong3d8status", "lingyong3d81", "lingyong3d81_after", "lingyong3d82", "lingyong3d82_after", "lingyong3d83", "lingyong3d83_after", "lingyong3d84", "lingyong3d84_after"],
              ai: {
                threaten: 3,
              },
            },

            lingyong3d8status: {
              trigger: {
                global: "phaseBegin",
              },
              forced: true,
              popup: false,
              content: function() {
                player.storage.lingyong3d8status = trigger.player;
                player.storage.lingyong3d81 = 0;
                player.storage.lingyong3d82 = 0;
                player.storage.lingyong3d83 = 0;
                player.storage.lingyong3d84 = 0;
              },
            },


            lingyong3d81: {
              trigger: {
                global: "phaseDrawBefore",
              },
              filter: function(event, player) {
                return player.storage.lingyong3d81 != 1 && player.storage.lingyong3d8status == event.player;
              },
              audio: "xinfu_sanwen",
              frequent: true,
              content: function() {
                "step 0"
                var next = player.judge(function(card) {
                  if (card.name == 'sha') return -2;
                  if (lib.filter.cardEnabled(card, player) && lib.filter.cardUsable(card, player) && game.hasPlayer(function(current) {
                      return player.canUse(card, current) && lib.filter.targetEnabled2(card, player, current);
                    }) && player.getUseValue(card) > 0) return 2;
                  return 0.5;
                });
                "step 1"
                if (result.judge > 0) {
                  event.lingyong_flag = 0;
                  player.chooseUseTarget(result.card, false, false);
                } else {
                  event.lingyong_flag = 1;
                  event.finish();
                }
                "step 2"
                if (event.lingyong_flag == 0) {
                  player.chooseBool('是否再次发动【灵涌】？').set('frequentSkill', 'lingyong3d81');
                } else event.finish();
                "step 3"
                if (result.bool) {
                  event.goto(0);
                } else event.finish();
              },
            },

            lingyong3d81_after: {
              trigger: {
                global: "phaseJudgeBegin",
              },
              forced: true,
              popup: false,
              content: function() {
                if (player.storage.lingyong3d8status == trigger.player) player.storage.lingyong3d81 = 1;
              },
            },

            lingyong3d82: {
              trigger: {
                global: "phaseUseBefore",
              },
              filter: function(event, player) {
                return player.storage.lingyong3d82 != 1 && player.storage.lingyong3d8status == event.player;
              },
              audio: "xinfu_sanwen",
              frequent: true,
              content: function() {
                "step 0"
                var next = player.judge(function(card) {
                  if (card.name == 'sha') return -2;
                  if (lib.filter.cardEnabled(card, player) && lib.filter.cardUsable(card, player) && game.hasPlayer(function(current) {
                      return player.canUse(card, current) && lib.filter.targetEnabled2(card, player, current);
                    }) && player.getUseValue(card) > 0) return 2;
                  return 0.5;
                });
                "step 1"
                if (result.judge > 0) {
                  event.lingyong_flag = 0;
                  player.chooseUseTarget(result.card, false, false);
                } else {
                  event.lingyong_flag = 1;
                  event.finish();
                }
                "step 2"
                if (event.lingyong_flag == 0) {
                  player.chooseBool('是否再次发动【灵涌】？').set('frequentSkill', 'lingyong3d81');
                } else event.finish();
                "step 3"
                if (result.bool) {
                  event.goto(0);
                } else event.finish();
              },
            },

            lingyong3d82_after: {
              trigger: {
                global: "phaseDrawBegin",
              },
              forced: true,
              popup: false,
              content: function() {
                if (player.storage.lingyong3d8status == trigger.player) player.storage.lingyong3d82 = 1;
              },
            },

            lingyong3d83: {
              trigger: {
                global: "phaseDiscardBefore",
              },
              filter: function(event, player) {
                return player.storage.lingyong3d83 != 1 && player.storage.lingyong3d8status == event.player;
              },
              audio: "xinfu_sanwen",
              frequent: true,
              content: function() {
                "step 0"
                var next = player.judge(function(card) {
                  if (card.name == 'sha') return -2;
                  if (lib.filter.cardEnabled(card, player) && lib.filter.cardUsable(card, player) && game.hasPlayer(function(current) {
                      return player.canUse(card, current) && lib.filter.targetEnabled2(card, player, current);
                    }) && player.getUseValue(card) > 0) return 2;
                  return 0.5;
                });
                "step 1"
                if (result.judge > 0) {
                  event.lingyong_flag = 0;
                  player.chooseUseTarget(result.card, false, false);
                } else {
                  event.lingyong_flag = 1;
                  event.finish();
                }
                "step 2"
                if (event.lingyong_flag == 0) {
                  player.chooseBool('是否再次发动【灵涌】？').set('frequentSkill', 'lingyong3d81');
                } else event.finish();
                "step 3"
                if (result.bool) {
                  event.goto(0);
                } else event.finish();
              },
            },

            lingyong3d83_after: {
              trigger: {
                global: "phaseUseBegin",
              },
              forced: true,
              popup: false,
              content: function() {
                if (player.storage.lingyong3d8status == trigger.player) player.storage.lingyong3d83 = 1;
              },
            },

            lingyong3d84: {
              trigger: {
                global: "phaseJieshuBefore",
              },
              filter: function(event, player) {
                return player.storage.lingyong3d84 != 1 && player.storage.lingyong3d8status == event.player;
              },
              audio: "xinfu_sanwen",
              frequent: true,
              content: function() {
                "step 0"
                var next = player.judge(function(card) {
                  if (card.name == 'sha') return -2;
                  if (lib.filter.cardEnabled(card, player) && lib.filter.cardUsable(card, player) && game.hasPlayer(function(current) {
                      return player.canUse(card, current) && lib.filter.targetEnabled2(card, player, current);
                    }) && player.getUseValue(card) > 0) return 2;
                  return 0.5;
                });
                "step 1"
                if (result.judge > 0) {
                  event.lingyong_flag = 0;
                  player.chooseUseTarget(result.card, false, false);
                } else {
                  event.lingyong_flag = 1;
                  event.finish();
                }
                "step 2"
                if (event.lingyong_flag == 0) {
                  player.chooseBool('是否再次发动【灵涌】？').set('frequentSkill', 'lingyong3d81');
                } else event.finish();
                "step 3"
                if (result.bool) {
                  event.goto(0);
                } else event.finish();
              },
            },

            lingyong3d84_after: {
              trigger: {
                global: "phaseDiscardBegin",
              },
              forced: true,
              popup: false,
              content: function() {
                if (player.storage.lingyong3d8status == trigger.player) player.storage.lingyong3d84 = 1;
              },
            },


            xuxiao3d8: {
              audio: "xinfu_qiai",
              trigger: {
                global: "discardEnd",
              },
              usable: 1,
              filter: function(event, player) {
                if (!event.cards) return false;
                if (event.cards) {
                  for (var i = 0; i < event.cards.length; i++) {
                    if (get.position(event.cards[i]) == 'd' && get.type(event.cards[i]) == 'basic' && get.color(event.cards[i]) == 'black') return true;
                  }
                }
                return false;
              },
              check: function(event, player) {
                var players = game.filterPlayer();
                var flag = 0;
                for (var i = 0; i < players.length; i++) {
                  if (lib.filter.targetEnabled2({
                      name: 'bingliang',
                      isCard: true
                    }, player, players[i])) {
                    if (get.attitude(player, players[i]) >= 0) return true;
                    else flag = 1;
                  }
                }
                if (flag == 1) return Math.random() > 0.25;
                return false;
              },
              content: function() {
                "step 0"
                player.chooseTarget('请选择一名角色，对其使用【兵粮寸断】，并令其摸两张牌', function(card, player, target) {
                  return lib.filter.targetEnabled2({
                    name: 'bingliang',
                    isCard: true
                  }, player, target);
                }).set('ai', function(target) {
                  return get.attitude(player, target) + 10;
                });
                "step 1"
                if (result.bool) {
                  event.target = result.targets[0];
                  var flag = 0;
                  for (var i = 0; i < trigger.cards.length; i++) {
                    if (get.position(trigger.cards[i]) == 'd' && get.type(trigger.cards[i]) == 'basic' && get.color(trigger.cards[i]) == 'black') {
                      result.targets[0].addJudge('bingliang', trigger.cards[i]);
                      flag = 1;
                      break;
                    }
                  }
                  if (flag == 0) event.finish();
                } else event.finish();
                "step 2"
                event.target.draw(2);
              },
            },

            qingxian3d8: {
              audio: "qingxian",
              trigger: {
                player: ["gainAfter", "equipAfter", "addJudgeAfter"],
              },
              filter: function(event, player) {
                return event.cards;
              },
              check: function(event, player) {
                if (event.name == 'addJudge') return true;
                if (event.name == 'equip') {
                  var cards = event.cards;
                  var flag1 = 0;
                  var flag2 = 0;
                  for (var i = 0; i < cards.length; i++) {
                    if (get.subtype(cards[i]) == 'equip1') flag1 = 1;
                    if (get.subtype(cards[i]) == 'equip2') flag2 = 1;
                  }
                  if (!player.isDamaged()) {
                    if (event.cards.length > 1) return false;
                    if (flag2 == 1) return false;
                    if (flag1 == 1) return Math.random() > 0.9;
                    return Math.random() > 0.75;
                  } else if (player.hp <= 2) {
                    if (flag == 1) return false;
                    return true;
                  } else {
                    if (event.cards.length > 1) return false;
                    if (flag2 == 1) return false;
                    if (flag1 == 1) return Math.random() > 0.8;
                    return Math.random() > 0.6;
                  }
                  return false;
                }
                if (event.name == 'gain') {
                  var cards = event.cards;
                  var flag = 0;
                  var tao = 0;
                  var sha = 0;
                  var value = 0;
                  for (var i = 0; i < cards.length; i++) {
                    if (get.value(cards[i]) >= 8) flag = 1;
                    if (cards[i].name == 'tao') tao = 1;
                    if (cards[i].name == 'sha') sha = 1;
                    value += get.value(cards[i]);
                  }
                  var avg = value / (event.cards.length + 0.0);
                  if (!player.isDamaged()) {
                    if (event.cards.length > 1) {
                      if (flag == 1) return false;
                      return avg <= 4;
                    }
                    if (avg <= 5) return Math.random() > 0.9;
                    return false;
                  } else if (player.hp <= 2) {
                    if (event.cards.length > 1) {
                      if (flag == 1 || tao == 1) return false;
                      return true;
                    }
                    if (avg <= 5) return true;
                    return Math.random() > 0.75;
                  } else {
                    if (event.cards.length > 1) {
                      if (flag == 1 || tao == 1) return false;
                      return Math.random() > 0.8;
                    }
                    if (avg <= 5) return true;
                    return Math.random() > 0.8;
                  }
                  return false;
                }
                return false;
              },
              content: function() {
                'step 0'
                player.discard(trigger.cards);
                var list = [];
                list.push(['基本', '', 'sha']);
                list.push(['基本', '', 'sha', 'fire']);
                list.push(['基本', '', 'sha', 'thunder']);
                if (lib.filter.cardUsable({
                    name: 'tao'
                  }, player) && game.hasPlayer(function(current) {
                    return player.canUse('tao', current);
                  })) {
                  list.push(['基本', '', 'tao']);
                }
                if (lib.filter.cardUsable({
                    name: 'jiu'
                  }, player) && game.hasPlayer(function(current) {
                    return player.canUse('jiu', current);
                  })) {
                  list.push(['基本', '', 'jiu']);
                }
                if (list.length) {
                  player.chooseButton(['是否视为使用一张基本牌？', [list, 'vcard']]).set('ai', function(button) {
                    var player = _status.event.player;
                    var card = {
                      name: button.link[2],
                      nature: button.link[3]
                    };
                    if (card.name == 'tao') {
                      if (player.hp == 1 || (player.hp == 2 && !player.hasShan()) || player.needsToDiscard()) {
                        return 5;
                      }
                      return 1;
                    }
                    if (card.name == 'sha') {
                      if (game.hasPlayer(function(current) {
                          return lib.filter.targetEnabled2(card, player, current) && get.effect(current, card, player, player) > 0
                        })) {
                        if (card.nature == 'fire') return 2.95;
                        if (card.nature == 'thunder' || card.nature == 'ice') return 2.92;
                        return 2.9;
                      }
                      return 0;
                    }
                    if (card.name == 'jiu') {
                      return 0.5;
                    }
                    return 0;
                  });
                }
                'step 1'
                if (result && result.bool && result.links[0]) {
                  var card = {
                    name: result.links[0][2],
                    nature: result.links[0][3]
                  };
                  player.chooseUseTarget(card, false, 'nodistance');
                }
              },
              mod: {
                targetInRange: function(card, player, target) {
                  if (_status.event.skill == 'qingxian3d8') return true;
                },
              },
              ai: {
                expose: 0.5,
                threaten: 1.5,
                effect: {
                  target: function(card, player, target, current) {
                    if (get.type(card) == 'delay') {
                      if (player.isDamaged()) return [0, 2];
                      return [0, 1];
                    }
                  },
                },
              },
            },


            juexiang3d8: {
              audio: "juexiang",
              trigger: {
                player: "dieBegin",
              },
              forced: true,
              skillAnimation: true,
              animationColor: "gray",
              content: function() {
                'step 0'
                player.chooseControl('heart2', 'diamond2', 'club2', 'spade2').set('ai', function(event) {
                  var players = game.filterPlayer();
                  var danger = 0;
                  var friend = 0;
                  for (var i = 0; i < players.length; i++) {
                    if (players[i] == player) continue;
                    if (get.attitude(player, players[i]) > 0) {
                      friend += 1;
                      if (players[i].hp <= 2) danger += 1;
                    }
                    if (get.attitude(player, players[i]) < 0) {
                      friend -= 1;
                      if (players[i].hp <= 2) danger -= 1;
                    }
                  }
                  if (friend >= 1 || danger <= -1) {
                    if (Math.random() >= 0.3) return 'heart2';
                    return 'diamond2';
                  } else if (friend <= -1 || danger >= 1) {
                    if (Math.random() >= 0.5) return 'spade2';
                    return 'club2';
                  }
                  var rand = Math.ceil(Math.random() * 6);
                  var suit = 'heart2';
                  if ([1, 4].contains(rand)) {
                    suit = 'diamond2';
                  } else if ([2, 5].contains(rand)) {
                    suit = 'club2';
                  } else if (rand == 3) {
                    suit = 'spade2';
                  } else {
                    suit = 'heart2';
                  }
                  return suit;
                });
                'step 1'
                if (result.control) {
                  game.log(player, '选择了' + get.translation(result.control));
                  var players = game.filterPlayer();
                  for (var i = 0; i < players.length; i++) {
                    if (players[i] == player) continue;
                    players[i].addSkill("juexiang3d8_" + result.control);
                  }
                }
              },
              subSkill: {
                heart2: {
                  charlotte: true,
                  marktext: "响",
                  mark: true,
                  mod: {
                    cardEnabled: function(card, player) {
                      if (get.suit(card) == 'heart') return false;
                    },
                    cardUsable: function(card, player) {
                      if (get.suit(card) == 'heart') return false;
                    },
                    cardRespondable: function(card, player) {
                      if (get.suit(card) == 'heart') return false;
                    },
                    cardSavable: function(card, player) {
                      if (get.suit(card) == 'heart') return false;
                    },
                    aiValue: function(player, card) {
                      if (get.suit(card) == 'heart') return -1;
                    },
                    aiUseful: function(player, card) {
                      if (get.suit(card) == 'heart') return -1;
                    },
                  },
                  intro: {
                    content: "不能使用或打出♥︎️牌",
                  },
                  ai: {
                    useful: -1,
                    value: -1,
                    effect: {
                      player: function(card, player, target, current) {
                        if (get.suit(card) == 'heart') return 'zeroplayertarget';
                      },
                    },
                  },
                  sub: true,
                },
                diamond2: {
                  charlotte: true,
                  marktext: "响",
                  mark: true,
                  mod: {
                    cardEnabled: function(card, player) {
                      if (get.suit(card) == 'diamond') return false;
                    },
                    cardUsable: function(card, player) {
                      if (get.suit(card) == 'diamond') return false;
                    },
                    cardRespondable: function(card, player) {
                      if (get.suit(card) == 'diamond') return false;
                    },
                    cardSavable: function(card, player) {
                      if (get.suit(card) == 'diamond') return false;
                    },
                    aiValue: function(player, card) {
                      if (get.suit(card) == 'diamond') return -1;
                    },
                    aiUseful: function(player, card) {
                      if (get.suit(card) == 'diamond') return -1;
                    },
                  },
                  intro: {
                    content: "不能使用或打出♦︎牌",
                  },
                  ai: {
                    useful: -1,
                    value: -1,
                    effect: {
                      player: function(card, player, target, current) {
                        if (get.suit(card) == 'diamond') return 'zeroplayertarget';
                      },
                    },
                  },
                  sub: true,
                },
                club2: {
                  charlotte: true,
                  marktext: "响",
                  mark: true,
                  mod: {
                    cardEnabled: function(card, player) {
                      if (get.suit(card) == 'club') return false;
                    },
                    cardUsable: function(card, player) {
                      if (get.suit(card) == 'club') return false;
                    },
                    cardRespondable: function(card, player) {
                      if (get.suit(card) == 'club') return false;
                    },
                    cardSavable: function(card, player) {
                      if (get.suit(card) == 'club') return false;
                    },
                    aiValue: function(player, card) {
                      if (get.suit(card) == 'club') return -1;
                    },
                    aiUseful: function(player, card) {
                      if (get.suit(card) == 'club') return -1;
                    },
                  },
                  ai: {
                    useful: -1,
                    value: -1,
                    effect: {
                      player: function(card, player, target, current) {
                        if (get.suit(card) == 'club') return 'zeroplayertarget';
                      },
                    },
                  },
                  intro: {
                    content: "不能使用或打出♣︎️牌",
                  },
                  sub: true,
                },
                spade2: {
                  charlotte: true,
                  marktext: "响",
                  mark: true,
                  mod: {
                    cardEnabled: function(card, player) {
                      if (get.suit(card) == 'spade') return false;
                    },
                    cardUsable: function(card, player) {
                      if (get.suit(card) == 'spade') return false;
                    },
                    cardRespondable: function(card, player) {
                      if (get.suit(card) == 'spade') return false;
                    },
                    cardSavable: function(card, player) {
                      if (get.suit(card) == 'spade') return false;
                    },
                    aiValue: function(player, card) {
                      if (get.suit(card) == 'spade') return -1;
                    },
                    aiUseful: function(player, card) {
                      if (get.suit(card) == 'spade') return -1;
                    },
                  },
                  ai: {
                    useful: -1,
                    value: -1,
                    effect: {
                      player: function(card, player, target, current) {
                        if (get.suit(card) == 'spade') return 'zeroplayertarget';
                      },
                    },
                  },
                  intro: {
                    content: "不能使用或打出♠︎️牌",
                  },
                  sub: true,
                },
              },
            },

            biwei3d8: {
              audio: "bingzheng",
              global: "biwei3d8_buff",
              shaRelated: true,
              trigger: {
                global: "useCardToPlayered",
              },
              filter: function(event, player) {
                if (event.target.hp < player.hp) return false;
                if (event.card.name != 'sha') return false;
                return true;
              },
              check: function(event, player) {
                var att = get.attitude(player, event.target);
                if (event.target == player) {
                  var cards = player.getCards("h");
                  var good = 0;
                  var trick = 0;
                  for (var i = 0; i < cards.length; i++) {
                    if (get.type(cards[i]) == 'trick' || get.type(cards[i]) == 'delay') {
                      trick += 1;
                      if (get.value(cards[i]) < 8) good += 1;
                    }
                  }
                  if (player.getEquip('bagua') || player.countCards('h', {
                      name: 'shan'
                    }) > 0) return good > 0;
                  return trick > 0;
                }
                if (att == 0) return false;
                if (att < 0) {
                  if (event.target.getEquip('bagua')) return true;
                  if (event.target.countCards("h") >= 5) return Math.random() > 0.8;
                  return Math.random() > 0.15 * event.target.countCards("h");
                }
                if (event.target.getEquip('bagua')) return false;
                if (event.target.countCards("h") >= 5) return Math.random() > 0.3;
                return Math.random() > 1 - 0.15 * event.target.countCards("h");
              },
              content: function() {
                "step 0"
                player.line(trigger.target, "green");
                trigger.target.chooseCard('he', 1, '将一张锦囊牌置于牌堆底以抵消' + get.translation(trigger.card)).set('filterCard', function(card) {
                  return get.type(card) == 'trick' || get.type(card) == 'delay'
                }).set('ai', function(card) {
                  return 10.5 - get.value(card);
                });
                "step 1"
                if (result.bool) {
                  event.card = result.cards[0];
                  trigger.target.lose(event.card, ui.special);
                  var cardx = ui.create.card();
                  cardx.classList.add('infohidden');
                  cardx.classList.add('infoflip');
                  trigger.target.$throw(cardx, 1000);
                  event.goto(2);
                } else {
                  game.log(trigger.target, '没有将一张锦囊牌置于牌堆底');
                  trigger.getParent().directHit.push(trigger.target);
                  event.finish();
                }
                "step 2"
                game.delay(0.5);
                "step 3"
                event.card.fix();
                ui.cardPile.appendChild(event.card);
                game.log(trigger.target, '将', event.card, '置于牌堆底');
                trigger.getParent().excluded.push(trigger.target);
                trigger.target.draw();
              },
            },

            biwei3d8_buff: {
              forced: true,
              mod: {
                aiValue: function(player, card, num) {
                  if (get.type(card) != 'trick' && get.type(card) != 'delay') return;
                  var players = game.filterPlayer();
                  for (var i = 0; i < players.length; i++) {
                    if (players[i].hasSkill("biwei3d8") && players[i].hp <= player.hp) return num + 2;
                  }
                },
                aiUseful: function(player, card, num) {
                  if (get.type(card) != 'trick' && get.type(card) != 'delay') return;
                  var players = game.filterPlayer();
                  for (var i = 0; i < players.length; i++) {
                    if (players[i].hasSkill("biwei3d8") && players[i].hp <= player.hp) return num + 4;
                  }
                },
              },
              ai: {},
            },

            juanlue3d8: {
              audio: "sheyan",
              global: "juanlue3d8_buff",
              trigger: {
                source: "damageEnd",
              },
              filter: function(event, player) {
                if (event.num <= 0) return false;
                if (get.itemtype(event.cards) != 'cards') return false;
                if (event.card.isCard) {
                  if (get.position(event.cards[0], true) == 'o') return true;
                }
                return false;
              },
              check: function(event, player) {
                return true;
              },
              content: function() {
                "step 1"
                event.card = trigger.cards[0];
                player.lose(event.card, ui.special);
                var cardx = ui.create.card();
                cardx.classList.add('infohidden');
                cardx.classList.add('infoflip');
                player.$throw(cardx, 1000);
                "step 2"
                game.delay(0.5);
                "step 3"
                event.card.fix();
                ui.cardPile.appendChild(event.card);
                game.log(player, '将', event.card, '置于牌堆底');
              },
              group: ["juanlue3d8_getcard"],
              subSkill: {
                getcard: {
                  audio: "sheyan",
                  trigger: {
                    global: "phaseZhunbeiEnd"
                  },
                  filter: function(event, player) {
                    return get.distance(player, event.player) <= 1;
                  },
                  frequent: true,
                  content: function() {
                    'step 0'
                    event.cards = get.bottomCards(2);
                    var content = ['牌堆底的两张牌', event.cards];
                    game.log(player, '观看了牌堆底的两张牌');
                    player.chooseControl('ok').set('dialog', content);
                    'step 1'
                    player.chooseTarget('是否令' + get.translation(trigger.player) + '获得两张牌？', function(card, player, target) {
                      return target == trigger.player;
                    }).set('ai', function(target) {
                      var val1 = get.value(event.cards[0]);
                      var val2 = get.value(event.cards[1]);
                      var att = get.attitude(player, target);
                      if (att == 0) return 0;
                      if (att > 0) {
                        if (target.hasJudge("lebu") || target.hasJudge("bingliang") || target.hasJudge("caomu")) {
                          if ((val1 <= 0 && val2 <= 4) || (val1 <= 0 && val2 <= 4)) return false;
                          return true;
                        }
                        return (val1 >= 8 && val2 >= 5) || (val1 >= 5 && val2 >= 8) || (val1 + val2 >= 14);
                      }
                      if (target.hasJudge("lebu") || target.hasJudge("bingliang") || target.hasJudge("caomu")) {
                        if ((val1 <= 0 && val2 <= 4) || (val1 <= 0 && val2 <= 4)) return true;
                        return false;
                      }
                      return (val1 <= 7 && val2 <= 0) || (val1 <= 0 && val2 <= 7) || (val1 + val2 <= 8) || (val1 <= 5 && val2 <= 5);
                    });
                    'step 2'
                    if (result.bool) {
                      game.log(player, '令', result.targets[0], '获得了牌堆底的两张牌');
                      player.line(result.targets[0], 'green');
                      result.targets[0].skip("phaseJudge");
                      result.targets[0].skip("phaseDraw");
                      result.targets[0].addTempSkill('baiban', "phaseUseBegin");
                      result.targets[0].gain(event.cards, 'gain2');
                    }
                  },
                },
              },
            },

            juanlue3d8_buff: {
              forced: true,
              ai: {
                effect: {
                  player: function(card, player, target, current) {
                    if (get.type(card) != 'delay') return;
                    var players = game.filterPlayer();
                    for (var i = 0; i < players.length; i++) {
                      if (players[i].hasSkill("juanlue3d8") && get.distance(players[i], target) <= 1 && get.attitude(players[i], target) > 0) {
                        return [1, -1, 1, 0];
                      }
                    }
                  },
                },
              },
            },


            xuyu3d8: {
              audio: "yuxu",
              trigger: {
                player: "useCardEnd",
              },
              filter: function(event, player) {
                return player.getHistory('useCard').length == 1 && player.isPhaseUsing();
              },
              check: function(event, player) {
                return true;
              },
              content: function() {
                player.addTempSkill('xuyu3d8_2');
                player.draw();
              },
              group: ["xuyu3d8_discard"],
              subSkill: {
                discard: {
                  audio: "yuxu",
                  trigger: {
                    player: "useCardEnd",
                  },
                  forced: true,
                  filter: function(event, player) {
                    return player.getHistory('useCard').length == 2 && player.isPhaseUsing() && player.hasSkill("xuyu3d8_2") && player.countCards('he') > 0;
                  },
                  content: function() {
                    player.chooseToDiscard('he', true);
                  },
                },
              }
            },

            xuyu3d8_2: {

            },

            shijian3d8: {
              audio: "xjshijian",
              trigger: {
                global: "useCardEnd",
              },
              filter: function(event, player) {
                return _status.currentPhase == event.player && event.player.getHistory('useCard').length == 3 && event.player.isPhaseUsing() && player != event.player;
              },
              check: function(event, player) {
                return get.attitude(player, event.player) >= 0;
              },
              content: function() {
                player.addTempSkill('shijian3d8_2');
                trigger.player.draw();
              },
              group: ["shijian3d8_draw"],
              subSkill: {
                draw: {
                  audio: "shijian",
                  trigger: {
                    global: "useCardEnd",
                  },
                  filter: function(event, player) {
                    return player.hasSkill("shijian3d8_2") && _status.currentPhase == event.player && event.player.getHistory('useCard').length == 4 && event.player.isPhaseUsing() && player != event.player;
                  },
                  forced: true,
                  content: function() {
                    player.draw();
                  },
                },
              }
            },

            shijian3d8_2: {

            },

            ziwen3d8: {
              audio: "xinfu_zuilun",
              trigger: {
                player: "phaseJieshuBegin",
              },
              forced: true,
              content: function() {
                var c1 = 0;
                var c2 = 0;
                var c3 = 0;
                if (player.getStat('damage')) c1 = 1;
                if (player.countCards("h", {
                    name: "sha"
                  }) > 0) c2 = 1;
                var list = [];
                for (var i = 0; i < game.dead.length; i++) {
                  if (game.dead[i].identity == "nei") list.push(game.dead[i]);
                }
                if (list.length > 0) c3 = 1;
                if (c2 == 1) {
                  var cards = player.getCards("h");
                  for (var i = 0; i < cards.length; i++) {
                    if (cards[i].name == 'sha') {
                      player.showCards(cards[i]);
                      break;
                    }
                  }
                }
                if (c1 + c2 + c3 > 0) player.draw(c1 + c2 + c3);
                else player.loseHp();
              },
              ai: {
                expose: 0.2,
                threaten: 1.2,
                effect: {
                  player: function(card, player, target, current) {
                    if (!player.isPhaseUsing()) return;
                    if (card.name != 'sha' || player.countCards("h", {
                        name: "sha"
                      }) != 1) return;
                    var list = [];
                    for (var i = 0; i < game.dead.length; i++) {
                      if (game.dead[i].identity == "nei") list.push(game.dead[i]);
                    }
                    if (list.length > 0) return;
                    if (player.getStat('damage')) return;
                    if (player.hp <= 1) return 'zeroplayertarget';
                    if (!target.countCards("h") || target.countCards("h") == 0) return;
                    var count = target.countCards("h");
                    if (player.hp <= 3) return 'zeroplayertarget';
                    if (Math.random() < (1.0 / Math.exp(count))) return;
                    else return 'zeroplayertarget';
                  },
                },
              },
            },

            weizhong3d8: {
              audio: "hongde",
              trigger: {
                player: "phaseUseEnd",
              },
              filter: function(event, player, name) {
                return player.storage.weizhong3d8.length < 3;
              },
              check: function(card) {
                return true;
              },
              init: function(player) {
                player.storage.weizhong3d8limit = 0;
                player.storage.weizhong3d8 = [];
              },
              content: function() {
                'step 0'
                event.count = 3 - player.storage.weizhong3d8.length;
                'step 1'
                event.list = ['摸牌', '增加手牌上限']
                player.chooseControl(event.list, true).set('prompt', '威重：选择一项执行').ai = function() {
                  if (player.countCards("h") <= player.getHandcardLimit()) return '摸牌';
                  var cards = player.getCards("h");
                  if (player.countCards("h") - player.getHandcardLimit() >= 2) return '增加手牌上限';
                  if (Math.random() > 0.5) return '增加手牌上限';
                  return '摸牌';
                };
                'step 2'
                event.count -= 1;
                if (result.control == '摸牌') player.draw();
                if (result.control == '增加手牌上限') {
                  player.addTempSkill('weizhong3d8_max', {
                    player: 'phaseAfter'
                  });
                  player.storage.weizhong3d8limit += 1;
                }
                if (event.count > 0) event.goto(1);
                else event.finish();
              },
              group: ["weizhong3d8_use", "weizhong3d8_refresh"],
              subSkill: {
                use: {
                  trigger: {
                    player: "useCardAfter",
                  },
                  forced: true,
                  popup: false,
                  filter: function(event, player, name) {
                    return _status.currentPhase == player && player.isPhaseUsing() && get.itemtype(event.cards[0]) == 'card';
                  },
                  content: function() {
                    var type = get.type(trigger.card, 'trick');
                    if (!player.storage.weizhong3d8.contains(type)) player.storage.weizhong3d8.push(type);
                  },
                },
                refresh: {
                  trigger: {
                    player: "phaseBegin",
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    player.storage.weizhong3d8limit = 0;
                    player.storage.weizhong3d8 = [];
                  },
                },
                max: {
                  mod: {
                    maxHandcard: function(player, num) {
                      return num + player.storage.weizhong3d8limit;
                    },
                  },
                  sub: true,
                },
              },
              ai: {
                expose: 0.2,
                threaten: 0.8,
                effect: {
                  player: function(card, player, target, current) {
                    if (!player.isPhaseUsing()) return;
                    var type = get.type(card, 'trick');
                    if (player.storage.weizhong3d8.contains(type)) return;
                    if (type == 'equip') return;
                    if (get.value(card) < 7) {
                      if (Math.random() < get.value(card) * 0.1) return 'zeroplayertarget';
                      else return;
                    }
                    return;
                  },
                },
              },

            },

            jingjing3d8: {
              audio: "dingpan",
              trigger: {
                global: "useCard",
              },
              filter: function(event, player) {
                if (event.player == player) return false;
                if (!event.card) return false;
                if (event.targets.length == 0) return false;
                var targets = event.targets;
                for (var i = 0; i < targets.length; i++) {
                  if (targets[i] == player) return false;
                }
                var card = event.card;
                var type = get.type(card, 'trick');
                //if(type!='basic' && type!='trick') return false; 
                var cards = player.getCards("he");
                for (var i = 0; i < cards.length; i++) {
                  if (get.type(cards[i], 'trick') == type) return true;
                }
                return false;
              },
              check: function(event, player) {
                var effect = 0;
                var targets = event.targets;
                for (var i = 0; i < targets.length; i++) {
                  effect += get.effect(targets[i], event.card, event.player, player);
                }
                if (effect >= 0) return false;
                var card = event.card;
                var type = get.type(card, 'trick');
                var cards = player.getCards("h");
                for (var i = 0; i < cards.length; i++) {
                  if (get.type(cards[i], 'trick') != type) continue;
                  if ((event.card.name == 'tao' || event.card.name == 'jiu') && event.targets[0].hp == 0) return true;
                  if (event.card.name == 'sha' && event.targets[0].hp == 1) return true;
                  if ((cards[i].name == 'jiu' || cards[i].name == 'tao') && player.hp == 1) continue;
                  if (get.type(cards[i], 'trick') == 'equip') {
                    if (get.subtype(cards[i]) == 'equip2' && player.hp <= 2) continue;
                    if (get.value(cards[i]) < get.value(event.card)) return true;
                  }
                  if (get.value(cards[i]) < get.value(event.card)) return true;
                  if (get.value(cards[i]) == get.value(event.card) && Math.random() > 0.5) return true;
                }
                return false;
              },
              content: function() {
                'step 0'
                player.chooseToDiscard("靖境：弃置一张相同类型的牌", 1, 'he', function(card, player) {
                  return get.type(card, 'trick') == get.type(trigger.card, 'trick');
                }).ai = function(card) {
                  if (player.hp == 1 && card.name == 'du' && player.countCards('h', {
                      name: 'tao'
                    }) == 0 && player.countCards('h', {
                      name: 'jiu'
                    }) == 0) return 0;
                  return 20 - get.value(card);
                };
                'step 1'
                if (result.bool) {
                  trigger.cancel();
                  game.log(player, '令', trigger.player, '的', trigger.card, '无效');

                } else event.finish();
              },
              ai: {
                threaten: 1.3,
                expose: 0.5,
              },
            },

            jiuyan3d8: {
              direct: true,
              audio: "canshi",
              trigger: {
                player: "phaseBegin",
              },
              content: function() {
                player.logSkill("jiuyan3d8", game.filterPlayer());
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  players[i].addTempSkill("jiuyan3d8_buff", "phaseAfter");
                }
              },
            },

            jiuyan3d8_buff: {
              enable: ["chooseToRespond", "chooseToUse"],
              filterCard: function(card) {
                return true;
              },
              position: 'he',
              selectCard: 2,
              check: function(card) {
                if (_status.event.logSkill == 'zongying3d8') {
                  return 5.5 - get.value(card);
                }
                if (_status.event.parent.name == 'zongying3d8') {
                  if (_status.event.player.getEquip('tengjia')) return 0;
                  if (_status.event.player.getEquip('bagua')) return 4 - get.value(card);
                  if (_status.event.player.countCards('h', {
                      name: 'shan'
                    }) > 0) return 0;
                  return 7 - get.value(card);
                }
                if (card.name == 'jiu' || card.name == 'tao') return 0;
                if (_status.event.type == 'dying') return 1 / Math.max(0.1, get.value(card));
                return 4 - get.value(card);
              },
              viewAs: {
                name: "jiu",
              },
              prompt: "将两张牌当酒使用或打出",
              viewAsFilter: function(player) {
                if ((!player.countCards('he')) || player.countCards('he') < 2) return false;
              },
              mod: {
                cardUsable: function(card, player, num) {
                  if (card.name == 'jiu') return Infinity;
                },
              },
              ai: {
                skillTagFilter: function(player) {
                  return player.countCards('he') >= 2;
                },
                threaten: 1.1,
                save: true,
                basic: {
                  useful: function(card, i) {
                    if (_status.event.player.hp > 1) {
                      if (i == 0) return 4;
                      return 1;
                    }
                    if (i == 0) return 7.3;
                    return 3;
                  },
                  value: function(card, player, i) {
                    if (player.hp > 1) {
                      if (i == 0) return 5;
                      return 1;
                    }
                    if (i == 0) return 7.3;
                    return 3;
                  },
                },
                order: function() {
                  return get.order({
                    name: 'jiu'
                  }) - 0.05;
                },
                result: {
                  target: function(player, target) {
                    if (_status.event.logSkill == 'zongying3d8') {
                      var cards = target.getCards("h");
                      var count = 0;
                      for (var i = 0; i < cards.length; i++) {
                        if (get.value(cards[i]) < 5.5) count += 1;
                      }
                      if (count >= 2) return 1;
                      return 0;
                    }
                    if (_status.event.parent.name == 'zongying3d8') {
                      if (target.getEquip('tengjia')) return 0;
                      if (target.getEquip('bagua')) return 1;
                      if (target.countCards('h', {
                          name: 'shan'
                        }) > 0) return 0;
                      return 1;
                    }
                    if (target && target.isDying()) return 2;
                    if (target && !target.isPhaseUsing()) return 0;
                    if (lib.config.mode == 'stone' && !player.isMin()) {
                      if (player.getActCount() + 1 >= player.actcount) return 0;
                    }
                    var shas = player.getCards('h', 'sha');
                    if (shas.length > 1 && (player.getCardUsable('sha') > 1 || player.countCards('h', 'zhuge'))) {
                      return 0;
                    }
                    shas.sort(function(a, b) {
                      return get.order(b) - get.order(a);
                    })
                    var card;
                    if (shas.length) {
                      for (var i = 0; i < shas.length; i++) {
                        if (lib.filter.filterCard(shas[i], target)) {
                          card = shas[i];
                          break;
                        }
                      }
                    } else if (player.hasSha() && player.needsToDiscard()) {
                      if (player.countCards('h', 'hufu') != 1) {
                        card = {
                          name: 'sha'
                        };
                      }
                    }
                    if (card) {
                      if (game.hasPlayer(function(current) {
                          return (get.attitude(target, current) < 0 &&
                            target.canUse(card, current, true, true) &&
                            !current.hasSkillTag('filterDamage', null, {
                              player: player,
                              card: card,
                              jiu: true,
                            }) &&
                            get.effect(current, card, target) > 0);
                        })) {
                        return 1;
                      }
                    }
                    return 0;
                  },
                },
                tag: {
                  save: 1,
                },
              },
            },

            zongying3d8: {
              audio: "chouhai",
              enable: "phaseUse",
              filter: function(event, player) {
                if (player.countCards('he') == 0) {
                  return false;
                }
                return !player.hasSkill('zongying3d8_empty');
              },
              content: function() {
                "step 0"
                player.chooseToUse({
                  name: 'jiu'
                }, '纵饮：是否使用一张【酒】？').set('ai', function(card) {
                  if (card.name == 'jiu') return 1;
                  return -1;
                }).logSkill = 'zongying3d8';
                "step 1"
                if (result.bool) {
                  player.chooseTarget('请选择一名角色，令其使用一张【酒】，或视为你对其使用一张【杀】', function(card, player, target) {
                    return target != player;
                  }).ai = function(target) {
                    if (get.effect(target, {
                        name: 'sha'
                      }, player, player) <= 0) return -1;
                    if (target.getEquip('tengjia')) return -1;
                    if (target.getEquip('bagua')) return 0.5;
                    if (target.countCards("he") == 1) return 2;
                    return Math.max(0.5, 4 - target.countCards("h"));
                  };
                } else event.finish();
                "step 2"
                if (result.bool) {
                  event.target = result.targets[0];
                  player.line(event.target, "red");
                  game.log(player, "选择了", event.target);
                  result.targets[0].chooseToUse({
                    name: 'jiu'
                  }, '纵饮：使用一张【酒】,或视为' + get.translation(player) + '对你使用一张【杀】');
                } else event.finish();
                "step 3"
                if (!result.bool) {
                  player.useCard({
                    name: 'sha',
                    isCard: true
                  }, event.target, false);
                  player.addTempSkill("zongying3d8_empty");
                }

              },
              ai: {
                order: 7,
                expose: 0.3,
                result: {
                  player: function(player, target) {
                    var players = game.filterPlayer();
                    var flag = 0;
                    for (var i = 0; i < players.length; i++) {
                      var target = players[i];
                      if (get.effect(target, {
                          name: 'sha'
                        }, player, player) > 0 && !target.getEquip('tengjia')) flag = 1;
                    }
                    if (flag == 0) return -1;
                    if (player.countCards('h', {
                        name: 'jiu'
                      }) > 0) return 1;
                    if (!player.hasSkill("jiuyan3d8")) return -1;
                    var cards = player.getCards("h");
                    var count = 0;
                    for (var i = 0; i < cards.length; i++) {
                      if (get.value(cards[i]) < 5.5) count += 1;
                    }
                    if (count >= 2) return 1;
                    return -1;
                  },
                },
                effect: {
                  player: function(card, player, target, current) {
                    if (card.name != 'jiu') return;
                    if (_status.event.parent.name != 'zongying3d8') return;
                    console.log(_status.event.parent.name);
                    return 1;
                  },
                },
                threaten: 2.0,
              },
            },

            zongying3d8_empty: {},

            jichi3d8: {
              audio: "guiming",
              unique: true,
              zhuSkill: true,
              trigger: {
                global: "useCardEnd",
              },
              filter: function(event, player) {
                if (event.player == player || event.player.group != 'wu') return false;
                if (event.card.name != 'jiu') return false;
                return true;
              },
              direct: true,
              content: function() {
                'step 0'
                trigger.player.chooseBool('是否发动【极侈】，令' + get.translation(player) + '摸一张牌？').set('choice', get.attitude(trigger.player, player) > 0);
                'step 1'
                if (result.bool) {
                  player.logSkill('jichi3d8');
                  trigger.player.line(player, 'green');
                  player.draw();
                }
              },
            },

            mijiao3d8: {
              audio: "yishe",
              trigger: {
                player: ["chooseToUseBegin"],
              },
              filter: function(event, player) {
                if (event.responded) return false;
                if (!event.filterCard({
                    name: 'shan'
                  }, player, event)) return false;
                if (event.name == 'chooseToRespond' && !lib.filter.cardRespondable({
                    name: 'shan'
                  }, player, event)) return false;
                var sour = event.getParent().player;
                return true;
              },
              frequent: true,
              content: function() {
                "step 0"
                var current = player;
                event.mijiao3d8_current = current.next;
                event.mijiao3d8_players = [];
                "step 1"
                event.mijiao3d8_current.chooseCard('he', '是否交给' + get.translation(player) + '一张牌？')
                  .ai = function(card) {
                    var att = get.attitude(event.mijiao3d8_current, player);
                    var value = get.value(card);
                    if (att == 0) {
                      if (value < 0) return 1;
                      return 0;
                    } else if (att < 0) {
                      if (value < 0) return 5;
                      if (!event.mijiao3d8_players || event.mijiao3d8_players.length == 0) {
                        if (value < 5 && card.name != 'shan') return 5 - get.value(card);
                      }
                      return 0;
                    } else if (att > 0) {
                      if (card.name == 'shan') return 5;
                      return 0;
                    }
                    return 0;
                  };
                "step 2"
                if (result.bool) {
                  player.gain(result.cards, event.mijiao3d8_current, 'give');
                  event.mijiao3d8_players.push(event.mijiao3d8_current);
                }
                event.mijiao3d8_current = event.mijiao3d8_current.next;
                if (event.mijiao3d8_current == player) event.goto(3);
                else event.goto(1);
                "step 3"
                if (!event.mijiao3d8_players || event.mijiao3d8_players.length == 0) {
                  trigger.untrigger();
                  trigger.responded = true;
                  trigger.result = {
                    bool: true,
                    card: {
                      name: 'shan'
                    }
                  };
                }
              },
              ai: {
                respondShan: true,
              },
            },

            yishe3d8: {
              audio: "bushi",
              trigger: {
                player: "phaseDiscardAfter",
              },
              filter: function(event, player) {
                return player.getHistory('lose', function(evt) {
                  return evt.type == 'discard' && evt.getParent('phaseDiscard') == event && evt.hs.filterInD('d').length > 0;
                }).length > 0 && game.hasPlayer(function(current) {
                  return current != player && get.distance(player, current, 'attack') <= 1;
                });
              },
              check: function(event, player) {
                var players = [];
                var current = player;
                current = current.next;
                while (current != player) {
                  if (current != player && get.distance(player, current, 'attack') <= 1) {
                    players.push(current);
                  }
                  current = current.next;
                }
                var cards = [];
                game.getGlobalHistory('cardMove', function(evt) {
                  if (evt.name == 'cardsDiscard' && evt.getParent('phaseDiscard') == event) cards.addArray(evt.cards.filterInD('d'));
                });
                game.countPlayer2(function(current) {
                  current.getHistory('lose', function(evt) {
                    if (evt.type != 'discard' || evt.getParent('phaseDiscard') != event) return;
                    cards.addArray(evt.cards.filterInD('d'));
                  })
                });
                cards.sort(function(a, b) {
                  if (get.value(a) < get.value(b)) return 1;
                  return -1;
                });
                var red = 0;
                for (var i = 0; i < cards.length; i++) {
                  if (get.color(cards[i]) == 'red') red += 1;
                }
                var count1 = 0;
                var count2 = 0;
                var val1 = 0;
                var val2 = 0;
                var rc = 0;
                for (var i = 0; i < players.length; i++) {
                  if (i >= cards.length) continue;
                  var att = get.attitude(player, players[i]);
                  if (att > 0 && get.value(cards[i]) > 0) {
                    count1 += 1;
                    val1 += get.value(cards[i]);
                    if (get.color(cards[i]) == 'red') rc += 1;
                  }
                  if (att < 0 && get.value(cards[i]) > 0) {
                    count2 += 1;
                    val2 += get.value(cards[i]);
                    if (get.color(cards[i]) == 'red') rc += 1;
                  }
                }
                if (player.hp == player.maxHp || red == 0) {
                  if (count1 > count2 && val1 > val2) return true;
                  return false;
                }
                if (rc >= 1 && (count1 >= count2 || val1 >= val2)) return true;
                var cp = 0;
                for (var i = 0; i < players.length; i++) {
                  if (get.attitude(player, players[i]) >= 0) cp += 1;
                }
                var cr = 0;
                for (var i = 0; i < cards.length; i++) {
                  if (get.color(cards[i]) == 'red' && get.value(cards[i]) > 0) cr += 1;
                }
                if (player.hp <= 2 && cr >= 1) {
                  if (cp >= 1) return true;
                  if (count2 - count1 <= (3 - player.hp)) return true;
                }
                if (player.hp >= 3 && cr >= 1) {
                  if (count1 >= count2 - 1 || val1 >= val2 - 3) return true;
                }
                return false;
              },
              content: function() {
                "step 0"
                event.yishe_players = [];
                event.yishe_index = 0;
                var players = game.filterPlayer();
                var current = player;
                current = current.next;
                while (current != player) {
                  if (current != player && get.distance(player, current, 'attack') <= 1) {
                    event.yishe_players.push(current);
                  }
                  current = current.next;
                }
                var cards = [];
                game.getGlobalHistory('cardMove', function(evt) {
                  if (evt.name == 'cardsDiscard' && evt.getParent('phaseDiscard') == trigger) cards.addArray(evt.cards.filterInD('d'));
                });
                game.countPlayer2(function(current) {
                  current.getHistory('lose', function(evt) {
                    if (evt.type != 'discard' || evt.getParent('phaseDiscard') != trigger) return;
                    cards.addArray(evt.cards.filterInD('d'));
                  })
                });
                event.yishe_cards = cards;

                "step 1"
                var target = event.yishe_players[event.yishe_index];
                event.yishe_target = target;
                event.yishe_target.chooseCardButton('义舍：是否获得一张牌？', event.yishe_cards, false).set('ai', function(button) {
                  var card = button.link;
                  var att = get.attitude(event.yishe_target, player);
                  if (player.hp == player.maxHp || get.color(card) == 'black' || att == 0) return get.value(card);
                  if (att > 0 && get.color(card) == 'red') return get.value(card) + 3;
                  if (att < 0 && get.color(card) == 'red') return get.value(card) - 3;
                  return get.value(card);
                });
                "step 2"
                if (result.bool) {
                  game.delay(0.5);
                  var card = result.links[0];
                  event.yishe_target.gain(card);
                  event.yishe_target.$gain2(card);
                  event.yishe_cards.remove(card);
                  game.log(event.yishe_target, '获得了', result.links);
                  if (get.color(card) == 'red') player.recover();
                } else {
                  game.log(event.yishe_target, '没有选择获得牌');
                }
                if (event.yishe_cards.length == 0) event.finish();
                event.yishe_index += 1;
                if (event.yishe_index == event.yishe_players.length) event.finish();
                else event.goto(1);
              },
              ai: {
                threaten: 1.3,
                expose: 0.2,
                effect: {
                  player: function(card, player, target, current) {
                    if (!player.isPhaseUsing()) return;
                    var limit = player.getHandcardLimit();
                    var cards = player.getCards("h");
                    var red = 0;
                    for (var i = 0; i < cards.length; i++) {
                      if (get.color(cards[i]) == 'red') red += 1;
                    }
                    if (get.color(card) == 'black') return;
                    if (player.hp == player.maxHp) return;
                    var candidates = [];
                    var current = player;
                    current = current.next;
                    while (current != player) {
                      if (current != player && get.distance(player, current, 'attack') <= 1 && get.attitude(player, current) >= 0) {
                        candidates.push(current);
                      }
                      current = current.next;
                    }
                    if (red - limit > player.maxHp - player.hp) return;
                    if (red - limit >= candidates.length) return 'zeroplayertarget';
                    if (red - limit >= 1 && candidates.length > 0) return 'zeroplayertarget';
                    return;
                  },
                },
              },
            },

            dikai3d8: {
              audio: "neifa",
              enable: ["chooseToUse"],
              filterCard: function(card) {
                return true;
              },
              position: 'h',
              selectCard: [2, Infinity],
              check: function(card) {
                //if(card.name=='sha') return 0;
                if (Math.random() < 0.5) return 6 - get.value(card);
                else return 5 - get.value(card);
              },
              viewAs: {
                name: "sha",
              },
              viewAsFilter: function(player) {
                if ((!player.countCards('h')) || player.countCards('h') < 2 || !player.isPhaseUsing()) return false;
              },
              prompt: "将至少两张手牌当杀使用",
              ai: {
                order: function() {
                  return get.order({
                    name: 'sha'
                  }) + 0.1;
                },
                useful: -1,
                value: -1,
                canLink: function(player, target, card) {
                  if (!target.isLinked() && !player.hasSkill('wutiesuolian_skill')) return false;
                  if (target.mayHaveShan() && !player.hasSkillTag('directHit_ai', true, {
                      target: target,
                      card: card,
                    }, true)) return false;
                  if (player.hasSkill('jueqing') || target.hasSkill('gangzhi') || target.hasSkill('gangzhi')) return false;
                  return true;
                },
                basic: {
                  useful: [5, 1],
                  value: [5, 1],
                },
              },
              group: ["dikai3d8_miss"],
              subSkill: {
                miss: {
                  frequent: true,
                  popup: false,
                  sub: true,
                  trigger: {
                    player: "shaMiss",
                  },
                  filter: function(event) {
                    return event.parent.skill == 'dikai3d8';
                  },
                  content: function() {
                    player.draw(trigger.parent.cards.length);
                  },
                },
              },
            },

            zhengsi3d8: {
              audio: "neifa",
              trigger: {
                player: "phaseJieshuBegin",
              },
              forced: true,
              content: function() {
                if (player.countCards("h") < 2) player.draw(2 - player.countCards("h"));
                else if (player.countCards("h") > 2) player.chooseToDiscard(player.countCards("h") - 2, true);
              },
            },



            taisi3d8: {
              audio: "mingjian",
              trigger: {
                global: "phaseEnd",
              },
              init: function(player) {
                player.storage.taisi3d8 = 0;
                player.storage.taisi3d8_players = [];
              },
              filter: function(event, player) {
                if (player.storage.taisi3d8 != 1) return false;
                var num = 0;
                game.countPlayer2(function(current) {
                  current.getHistory('lose', function(evt) {
                    if (evt.position == ui.discardPile) num += evt.cards.filterInD('d').length;
                  })
                });
                game.getGlobalHistory('cardMove', function(evt) {
                  if (evt.name == 'cardsDiscard') num += evt.cards.filterInD('d').length;
                })
                return num > 0;
              },
              check: function(event, player) {
                var cards = [];
                game.countPlayer2(function(current) {
                  current.getHistory('lose', function(evt) {
                    if (evt.position == ui.discardPile) cards.addArray(evt.cards.filterInD('d'));
                  })
                });
                game.getGlobalHistory('cardMove', function(evt) {
                  if (evt.name == 'cardsDiscard') cards.addArray(evt.cards.filterInD('d'));
                })
                for (var i = 0; i < cards.length; i++) {
                  if (get.value(cards[i]) > 0) return true;
                }
                var players = player.storage.taisi3d8_players;
                for (var i = 0; i < players.length; i++) {
                  if (get.attitude(player, players[i]) < 0) return true;
                }
                return false;
              },
              content: function() {
                "step 0"
                var cards = [];
                game.countPlayer2(function(current) {
                  current.getHistory('lose', function(evt) {
                    if (evt.position == ui.discardPile) cards.addArray(evt.cards.filterInD('d'));
                  })
                });
                game.getGlobalHistory('cardMove', function(evt) {
                  if (evt.name == 'cardsDiscard') cards.addArray(evt.cards.filterInD('d'));
                })
                player.chooseCardButton('选择一张牌', cards, function(button) {
                  return true;
                }, true).set('ai', function(button) {
                  if (button.link.name == 'tao') return 20;
                  if (button.link.name == 'jiu') return 15;
                  if (button.link.name == 'shan') return 15;
                  var count1 = 0;
                  var count2 = 0;
                  for (var i = 0; i < cards.length; i++) {
                    if (get.value(cards[i]) > 0) count1 += 1;
                    if (get.value(cards[i]) >= 5) count2 += 1;
                  }
                  var players = player.storage.taisi3d8_players;
                  var cp = 0;
                  for (var i = 0; i < players.length; i++) {
                    if (get.attitude(player, players[i]) < 0) cp += 1;
                  }
                  if (count1 == 0 || count2 == 0) {
                    if (cp >= 1) return -get.value(button.link);
                    return get.value(button.link);
                  }
                  return get.value(button.link);
                }).set('filterButton', function(button) {
                  return true;
                });
                'step 1'
                if (result.bool) {
                  event.card = result.links[0];
                  player.chooseTarget('太思：选择一名角色获得' + get.translation(event.card), function(card, player, target) {
                    return true;
                  }, true).ai = function(target) {
                    var att = get.attitude(player, target);
                    var val = get.value(event.card);
                    if (event.card.name == 'tao') {
                      if (target == player) {
                        if (player.storage.taisi3d8_players.length > 0 && player.storage.taisi3d8_players.indexOf(target) >= 0) return 100;
                        return 1;
                      }
                      if (player.storage.taisi3d8_players.length == 0) return att;
                      if (player.storage.taisi3d8_players.indexOf(target) >= 0) {
                        if (att > 0) return 100;
                        return -1;
                      }
                      return att;
                    }
                    if (event.card.name == 'jiu' || event.card.name == 'shan') {
                      if (target == player) {
                        if (player.storage.taisi3d8_players.length > 0 && player.storage.taisi3d8_players.indexOf(target) >= 0) return 100;
                        if (target.hp <= 2) return 5 * (3 - target.hp);
                        return 3;
                      }
                      if (player.storage.taisi3d8_players.length == 0) {
                        if (att > 0) return 1;
                        return -1;
                      }
                      if (player.storage.taisi3d8_players.indexOf(target) >= 0) {
                        if (att > 0) return 10;
                        return 4;
                      }
                      if (att > 0) return 1;
                      return -1;
                    }

                    if (val < 0) {
                      if (att < 0) {
                        if (player.storage.taisi3d8_players.length == 0) return -att;
                        if (player.storage.taisi3d8_players.indexOf(target) >= 0) return 100;
                        return -att;
                      }
                      if (player.storage.taisi3d8_players.length == 0) return -att;
                      if (player.storage.taisi3d8_players.indexOf(target) >= 0) return 0;
                      return -att;
                    }
                    if (att < 0) {
                      if (player.storage.taisi3d8_players.length == 0) return att;
                      if (player.storage.taisi3d8_players.indexOf(target) >= 0) {
                        if (val < 5) return 10;
                        return 1;
                      }
                      return att;
                    }
                    if (player.storage.taisi3d8_players.length == 0) return att;
                    if (player.storage.taisi3d8_players.indexOf(target) >= 0) return 20;
                    return att;
                  };
                }
                'step 2'
                if (result.bool) {
                  event.target = result.targets[0];
                  event.target.gain(event.card, "gain");
                  if (player.storage.taisi3d8_players.length > 0 && player.storage.taisi3d8_players.indexOf(event.target) >= 0) player.draw(2);
                } else event.finish();
              },
              group: ["taisi3d8_change", "taisi3d8_init", "taisi3d8_damage"],
              subSkill: {
                "change": {
                  sub: true,
                  trigger: {
                    player: "changeHp",
                  },
                  forced: true,
                  popup: false,
                  silent: true,
                  content: function() {
                    player.storage.taisi3d8 = 1;
                  },
                },
                "init": {
                  sub: true,
                  trigger: {
                    global: "phaseBegin",
                  },
                  forced: true,
                  popup: false,
                  silent: true,
                  content: function() {
                    player.storage.taisi3d8 = 0;
                    player.storage.taisi3d8_players = [];
                  },
                },
                damage: {
                  sub: true,
                  trigger: {
                    player: "damageAfter",
                  },
                  forced: true,
                  popup: false,
                  silent: true,
                  content: function() {
                    if (trigger.source) player.storage.taisi3d8_players.push(trigger.source);
                  },
                },
              },
              ai: {
                maixie: true,
                "maixie_hp": true,
                effect: {
                  target: function(card, player, target) {
                    if (get.tag(card, 'damage')) {
                      if (player.hasSkillTag('jueqing', false, target)) return [1, -2];
                      if (!target.hasFriend()) return;
                      var num = 0.3;
                      if (get.attitude(player, target) > 0) {
                        num = 0.5;
                      }
                      if (target.hp >= 4) return [1, num * 2];
                      if (target.hp == 3) return [1, num * 1.5];
                      if (target.hp == 2) return [1, num * 0.5];
                    }
                  },

                },
              },

            },

            quche3d8: {
              skillAnimation: true,
              animationColor: "gray",
              limited: true,
              audio: "huituo",
              trigger: {
                player: "phaseZhunbeiBegin",
              },
              init: function(player) {
                player.storage.quche3d8 = 0;
              },
              filter: function(event, player) {
                return player.maxHp - player.hp > 0;
              },
              check: function(event, player) {
                var count = player.maxHp - player.hp;
                if (count == 1) return false;
                var players = game.filterPlayer();
                var count1 = 0;
                var count2 = 0;
                var count3 = 0;
                var count4 = 0;
                var count5 = 0;
                for (var i = 0; i < players.length; i++) {
                  if (get.attitude(player, players[i]) <= 0) count1 += 1;
                  if (get.attitude(player, players[i]) > 0) count2 += 1;
                }
                var cards = player.getCards("h");
                for (var i = 0; i < cards.length; i++) {
                  if (get.color(cards[i]) == 'black' && get.value(cards[i]) <= 5) count3 += 1;
                  if (get.color(cards[i]) == 'red' && get.value(cards[i]) < 0) count4 += 1;
                  if (get.color(cards[i]) == 'red' && get.value(cards[i]) >= 0) count5 += 1;
                }
                if (count3 + count4 + count5 < count) return false;
                var count6 = 0;
                if (count4 > 0 && count1 > 0) count6 += count4;
                if (count5 > 0 && count2 > 0) count6 += count5;
                if (count >= 3) count6 = Math.min(count6, count - 2);
                else count6 = Math.min(count6, 1);
                var count7 = 0;
                for (var i = 0; i < players.length; i++) {
                  if (!lib.filter.targetEnabled2({
                      name: 'sha'
                    }, player, players[i])) continue;
                  if (get.distance(player, players[i], 'attack') > 1 + count6) continue;
                  if (get.effect(players[i], {
                      name: 'sha'
                    }, player) > 0) count7 += 1;
                }
                if (count7 == 0 || count3 == 0) return false;
                if (count7 > 0 && count3 + count6 >= count) return true;
                return false;
              },
              content: function() {
                "step 0"
                player.awakenSkill('quche3d8');
                player.addTempSkill('quche3d8_buff');
                event.quche_count = player.maxHp - player.hp;
                event.quche_count1 = 0;
                "step 1"
                var list = [];
                var cards = player.getCards("he");
                var count1 = 0;
                var count2 = 0;
                for (var i = 0; i < cards.length; i++) {
                  if (get.color(cards[i]) == 'black') count1 += 1;
                  if (get.color(cards[i]) == 'red') count2 += 1;
                }
                if (count1 > 0) list.push("使用杀");
                if (count2 > 0) list.push("给出牌");
                if (count1 == 0) event.goto(5);
                else if (count2 == 0) event.goto(3);

                player.chooseControl(list, true).set('prompt', '驱车：选择一项执行').ai = function() {
                  var players = game.filterPlayer();
                  for (var i = 0; i < players.length; i++) {
                    var target = players[i];
                    if (get.effect(target, {
                        name: 'sha'
                      }, player) > 0 && player.canUse('sha', target)) return "使用杀";
                  }
                  return "给出牌";
                }
                "step 2"
                if (result.control == "使用杀") event.goto(3);
                if (result.control == "给出牌") event.goto(5);
                "step 3"
                player.chooseCardTarget({
                  filterCard: function(card) {
                    return get.color(card) == 'black';
                  },
                  position: 'he',
                  selectCard: [1, 1],
                  selectTarget: 1,
                  filterTarget: function(card, player, target) {
                    return player.canUse('sha', target);
                  },
                  ai1: function(card) {
                    return 10 - get.value(card);
                  },
                  ai2: function(target) {
                    return get.effect(target, {
                      name: 'sha'
                    }, player);
                  },
                  prompt: '驱车：将一张黑色牌当做【杀】对一名角色使用',
                });
                'step 4'
                if (result.bool) {
                  player.useCard({
                    name: 'sha',
                    isCard: true
                  }, result.cards, result.targets, true, false).viewAs = true;
                  event.quche_count -= 1;
                  player.storage.quche3d8 += 1;
                  if (event.quche_count == 0) event.finish();
                  else event.goto(1);
                } else event.finish();

                'step 5'
                player.chooseCardTarget({
                  filterCard: function(card) {
                    return get.color(card) == 'red';
                  },
                  position: 'he',
                  selectCard: [1, 1],
                  selectTarget: 1,
                  filterTarget: function(card, player, target) {
                    return player != target;
                  },
                  ai1: function(card) {
                    if (get.value(card) < 0) return 20;
                    return get.value(card);
                  },
                  ai2: function(target) {
                    var cards = player.getCards("he");
                    var count = 0;
                    for (var i = 0; i < cards.length; i++) {
                      if (get.color(cards[i]) == 'red' && get.value(cards[i]) < 0) count += 1;
                    }
                    if (count > 0) return -get.attitude(player, target);
                    return get.attitude(player, target);
                  },
                  prompt: '驱车：将一张红色牌交给其他角色',
                });
                'step 6'
                if (result.bool) {
                  result.targets[0].gain(result.cards, player, 'give');
                  event.quche_count -= 1;
                  player.storage.quche3d8 += 1;
                  if (event.quche_count == 0) event.finish();
                  else event.goto(1);
                } else event.finish();
              },
            },

            quche3d8_buff: {
              mod: {
                globalFrom: function(from, to, distance) {
                  return distance - from.storage.quche3d8;
                },
              },
            },

            qianlong3d8: {
              mode: ["identity"],
              zhuSkill: true,
              audio: "xingshuai",
              trigger: {
                global: "dieBefore",
              },
              forced: true,
              filter: function(event, player) {
                return event.player != game.zhu && _status.currentPhase == player && player.hasZhuSkill("qianlong3d8") && event.player.group == 'wei';
              },
              content: function() {
                trigger.player.identity = 'fan';
                trigger.player.setIdentity('fan');
                trigger.player.identityShown = true;
              },
            },

            lunzhan3d8: {
              audio: "gushe",
              enable: "phaseUse",
              usable: 1,
              filter: function(event, player) {
                return game.hasPlayer(function(current) {
                  return player.canCompare(current);
                });
              },
              content: function() {
                'step 0'
                player.chooseTarget("论战：选择一名角色成为拼点的目标", function(card, player, target) {
                  return player.canCompare(target);
                }, false).ai = function(target) {
                  var att = get.attitude(player, target);
                  var hs = player.getCards('h');
                  if (att == 0) return 0.1;
                  else if (att > 0) {
                    if (!player.isDamaged()) return 0;
                    if (target.countCards("h") >= 3 && target.hp >= 3) {
                      if (player.hp == 1) return 4;
                      return 2;
                    }
                    if (player.hp == 1) return 3;
                    return 1;
                  }
                  if (target.countCards("h") >= 3 && target.hp >= 3) return 1;
                  if (target.countCards("h") <= 2 && target.hp <= 2) return 4;
                  return 3;
                }
                'step 1'
                if (result.bool) {
                  event.target = result.targets[0];
                  player.chooseToCompare(event.target);
                } else event.finish();
                'step 2'
                if (result.bool) {
                  player.recover();
                  event.finish();
                } else {
                  player.loseHp();
                  if (player.canCompare(event.target)) event.goto(3);
                  else event.finish();
                }
                'step 3'
                event.list = ['继续', '不继续']
                player.chooseControl(event.list, true).set('prompt', '论战：是否继续拼点？').ai = function() {
                  if (get.attitude(player, event.target) <= 0) return '不继续';
                  var hs = player.getCards('h');
                  if (player.hp == 1) {
                    for (var i = 0; i < hs.length; i++) {
                      if (hs[i].name != 'tao' && hs[i].number >= 12) return '继续';
                    }
                    return '不继续';
                  }
                  for (var i = 0; i < hs.length; i++) {
                    if (get.value(hs[i]) <= 6 && hs[i].number >= 11) return '继续';
                  }
                  return '不继续';
                };
                'step 4'
                if (result.control == '继续') {
                  player.chooseToCompare(event.target);
                } else event.finish();
                'step 5'
                if (result.bool) {
                  player.recover();
                  event.finish();
                } else {
                  player.loseHp();
                  if (player.canCompare(event.target)) event.goto(3);
                  else event.finish();
                }
              },
              ai: {
                order: function(player) {
                  if (_status.event.player.hp <= 2) return 9;
                  return 1;
                },
                result: {
                  player: function(player, target) {
                    var hs = player.getCards('h');
                    if (!player.isDamaged()) {
                      for (var i = 0; i < hs.length; i++) {
                        if (get.value(hs[i]) < 5 && hs[i].number >= 12) return 1;
                      }
                      return 0;
                    }
                    if (player.hp == 1) {
                      var flag = 0;
                      for (var i = 0; i < hs.length; i++) {
                        if (hs[i].name != 'tao' && hs[i].number >= 12) return 1;
                        if (hs[i].name != 'tao' && hs[i].number >= 9) flag = 1;
                      }
                      var has = game.hasPlayer(function(current) {
                        return player != current && player.canCompare(current) && current.hp >= 2 && current.countCards("h") >= 2;
                      });
                      if (has && flag == 1) return 1;
                      return 0;
                    }
                    for (var i = 0; i < hs.length; i++) {
                      if (get.value(hs[i]) <= 6 && hs[i].number >= 11) return 1;
                    }
                    return 0;
                  },
                },
              },
            },

            boya3d8: {
              audio: "jici",
              global: "boya3d8_global",
              trigger: {
                player: "loseAfter",
                global: ["equipAfter", "addJudgeAfter", "gainAfter", "loseAsyncAfter"],
              },
              frequent: true,
              filter: function(event, player) {
                if (!_status.currentPhase) return false;
                if (player == _status.currentPhase) return false;
                if (player.countCards('h')) return false;
                var evt = event.getl(player);
                return evt && evt.player == player && evt.hs && evt.hs.length > 0;
              },
              content: function() {
                player.draw(2);
              },
              ai: {
                threaten: 0.8,
                effect: {
                  target: function(card) {
                    if (card.name == 'guohe' || card.name == 'liuxinghuoyu') return 0.5;
                  },
                },
                noh: true,
                skillTagFilter: function(player, tag) {
                  if (tag == 'noh') {
                    if (_status.currentPhase == player) return false;
                  }
                },
              },
              subSkill: {
                global: {
                  trigger: {
                    player: "loseAfter",
                    global: ["equipAfter", "addJudgeAfter", "gainAfter", "loseAsyncAfter"],
                  },
                  frequent: true,
                  filter: function(event, player) {
                    if (player.hasSkill("boya3d8")) return false;
                    if (player == _status.currentPhase) return false;
                    if (!_status.currentPhase) return false;
                    if (!_status.currentPhase.hasSkill("boya3d8")) return false;
                    if (player.countCards('h')) return false;
                    var evt = event.getl(player);
                    return evt && evt.player == player && evt.hs && evt.hs.length > 0;
                  },
                  content: function() {
                    player.draw(1);
                  },
                  ai: {
                    threaten: 0.8,
                    effect: {
                      target: function(card) {
                        if (!_status.currentPhase.hasSkill("boya3d8")) return;
                        if (card.name == 'guohe' || card.name == 'liuxinghuoyu') return 0.5;
                      },
                    },
                    noh: true,
                    skillTagFilter: function(player, tag) {
                      if (tag == 'noh') {
                        if (_status.currentPhase == player || !_status.currentPhase.hasSkill("boya3d8")) return false;
                      }
                    },
                  },
                },
              },
            },

            dongcha3d8: {
              audio: "zhongjian",
              trigger: {
                global: "phaseBegin",
              },
              init: function(player) {
                player.storage.dongcha3d8 = [];
                player.storage.dongcha3d8tag = 0;
              },
              filter: function(event, player) {
                if (player == event.player) return false;
                return player.countCards("h") > 0 && event.player.countCards("h") > 0;
              },
              check: function(event, player) {
                if (get.attitude(player, event.player) >= 0) return true;
                var cards = player.getCards("h");
                if (cards.length == 1) {
                  var card = cards[0];
                  if (card.name == 'jiu' || card.name == 'tao' || card.name == 'shan') return false;
                }
                return true;
              },
              content: function() {
                'step 0'
                event.target = trigger.player;
                event.target.chooseCard('h', '交给' + get.translation(player) + '一张牌', true)
                  .ai = function(card) {
                    return 20 - get.value(card);
                  };
                'step 1'
                if (result.bool) {
                  event.target.line(player, 'green');
                  event.card = result.cards[0];
                  player.chooseCardButton('洞察', result.cards, 1, true).set('ai', function(button) {
                    return 0;
                  });
                } else event.finish();
                'step 2'
                if (result.bool) {
                  event.target.lose(result.links, ui.special);
                  player.storage.dongcha3d8 = player.storage.dongcha3d8.concat(result.links);
                  player.syncStorage('dongcha3d8');
                  player.markSkill('dongcha3d8');
                  game.log(event.target, "扣置了一张牌");
                  player.chooseCard('h', '扣置一张牌', true)
                    .ai = function(card) {
                      var color = get.color(event.card);
                      var att = get.attitude(player, event.target);
                      if (att >= 0 || (att < 0 && get.distance(event.target, player, 'attack') > 1)) {
                        if (get.color(card) == color) return 0.1;
                        return 8 - get.value(card);
                      }
                      return 8 - get.value(card);
                    };
                }
                'step 3'
                if (result.bool) {
                  player.lose(result.cards, ui.special);
                  player.storage.dongcha3d8 = player.storage.dongcha3d8.concat(result.cards);
                  player.syncStorage('dongcha3d8');
                  player.markSkill('dongcha3d8');
                  game.log(player, "扣置了一张牌");
                  player.storage.dongcha3d8tag = 1;
                } else event.finish();
              },
              mark: true,
              marktext: "察",
              intro: {
                name: "洞察",
                content: "cardCount",
                onunmark: function(storage, player) {
                  if (storage && storage.length) {
                    player.$throw(storage, 1000);
                    game.cardsDiscard(storage);
                    game.log(storage, '被置入了弃牌堆');
                    storage.length = 0;
                  }
                },
              },
              ai: {
                expose: 0.7,
                threaten: 1.8,
              },
              group: ["dongcha3d8_end"],
              subSkill: {
                end: {
                  trigger: {
                    global: "phaseEnd",
                  },
                  forced: true,
                  filter: function(event, player) {
                    if (event.player == player) return false;
                    return player.storage.dongcha3d8tag == 1 && player.storage.dongcha3d8.length > 0;
                  },
                  content: function() {
                    'step 0'
                    player.storage.dongcha3d8tag = 0;
                    player.chooseCardButton('洞察：选择一张牌获得', true, player.storage.dongcha3d8).set('ai', function(button) {
                      return get.value(button.link);
                    });
                    'step 1'
                    if (result.bool) {
                      player.storage.dongcha3d8.remove(result.links[0]);
                      player.syncStorage('dongcha3d8');
                      player.gain(result.links[0], 'gain2');
                      var card = player.storage.dongcha3d8[0];
                      player.storage.dongcha3d8.remove(card);
                      player.syncStorage('dongcha3d8');
                      trigger.player.gain(card, 'gain2');
                      if (!player.storage.dongcha3d8.length) {
                        player.unmarkSkill('dongcha3d8');
                      }
                    } else event.finish();
                  },
                },
              },
            },

            zhijie3d8: {
              audio: "caishi",
              group: ["zhijie3d8_shan", "zhijie3d8_wuxie"],
              subSkill: {
                shan: {
                  audio: "caishi",
                  trigger: {
                    player: ["chooseToRespondBegin", "chooseToUseBegin"],
                  },
                  filter: function(event, player) {
                    if (player.storage.dongcha3d8tag != 1) return false;
                    if (player.storage.dongcha3d8.length != 2) return false;
                    if (get.color(player.storage.dongcha3d8[0]) != get.color(player.storage.dongcha3d8[1])) return false;
                    if (event.responded) return false;
                    if (!event.filterCard({
                        name: 'shan'
                      }, player, event)) return false;
                    if (event.name == 'chooseToRespond' && !lib.filter.cardRespondable({
                        name: 'shan'
                      }, player, event)) return false;
                    return true;
                  },
                  prompt: "你可以将你武将牌上相同颜色的两张牌当【闪】使用",
                  check: function() {
                    return 1
                  },
                  content: function() {
                    "step 0"
                    player.storage.dongcha3d8tag = 0;
                    var cards = [];
                    for (var i = 0; i < player.storage.dongcha3d8.length; i++) {
                      cards.push(player.storage.dongcha3d8[i]);
                    }
                    player.$throw(cards);
                    ui.discardPile.appendChild(cards[0]);
                    ui.discardPile.appendChild(cards[1]);
                    player.storage.dongcha3d8 = [];
                    player.syncStorage('dongcha3d8');
                    if (!player.storage.dongcha3d8.length) {
                      player.unmarkSkill('dongcha3d8');
                    }
                    'step 1'
                    trigger.untrigger();
                    trigger.responded = true;
                    trigger.result = {
                      bool: true,
                      card: {
                        name: 'shan'
                      }
                    }
                  },
                  ai: {
                    respondShan: true,
                    skillTagFilter: function(player, tag, arg) {
                      if (player.storage.dongcha3d8tag != 1 || player.storage.dongcha3d8.length != 2) return false;
                    },
                  },
                  sub: true,
                },
                wuxie: {
                  audio: "caishi",
                  enable: ["chooseToUse", "chooseToRespond"],
                  filterCard: function() {
                    return false
                  },
                  selectCard: -1,
                  viewAsFilter: function(player) {
                    if (player.storage.dongcha3d8tag != 1) return false;
                    if (player.storage.dongcha3d8.length != 2) return false;
                    if (get.color(player.storage.dongcha3d8[0]) == get.color(player.storage.dongcha3d8[1])) return false;
                    return true;
                  },
                  viewAs: {
                    name: "wuxie",
                  },
                  prompt: "你可以将你武将牌上不同颜色的两张牌当【无懈可击】使用",
                  onuse: function(result, player) {
                    player.storage.dongcha3d8tag = 0;
                    var cards = [];
                    for (var i = 0; i < player.storage.dongcha3d8.length; i++) {
                      cards.push(player.storage.dongcha3d8[i]);
                    }
                    player.$throw(cards);
                    ui.discardPile.appendChild(cards[0]);
                    ui.discardPile.appendChild(cards[1]);
                    player.storage.dongcha3d8 = [];
                    player.syncStorage('dongcha3d8');
                    if (!player.storage.dongcha3d8.length) {
                      player.unmarkSkill('dongcha3d8');
                    }
                  },
                  check: function() {
                    return 1
                  },
                  ai: {
                    threaten: 0.8,
                    basic: {
                      useful: [6, 4],
                      value: [6, 4],
                    },
                    result: {
                      player: 1,
                    },
                    expose: 0.2,
                  },
                  sub: true,
                },
              },
            },

            gushou3d8: {
              audio: "jlsg_jushou",
              trigger: {
                player: ["useCardAfter", "useCardCancelled"],
              },
              filter: function(event, player) {
                if (get.type(event.card, false) == 'basic') return true;
                return false;
              },
              check: function(event, player) {
                var cards = player.getCards('h');
                for (var i = 0; i < cards.length; i++) {
                  if (cards[i].name == event.card.name) return false;
                }
                return true;
              },
              content: function() {
                player.showHandcards();
                var cards = player.getCards('h');
                var has_card = 0;
                for (var i = 0; i < cards.length; i++) {
                  if (cards[i].name == trigger.card.name) has_card = 1;
                }
                if (has_card == 0) player.draw();
              },
              ai: {
                expose: 0.2,
              },
            },

            tandi3d8: {
              audio: "xinfu_dianhu",
              trigger: {
                player: "phaseDrawBefore",
              },
              global: "tandi3d8_buff",
              init: function(player) {
                player.storage.tandi3d8 = 0;
                player.storage.tandi3d8_first = player;
              },
              filter: function(event, player) {
                if (player.storage.tandi3d8 != 0) return false;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i] != player && players[i].countCards("hej") > 0) return true;
                }
                return false;
              },
              check: function(event, player) {
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i] == player) continue;
                  var att = get.attitude(player, players[i]);
                  if (att > 0 && players[i].countCards("j") > 0) return true;
                  if (att < 0 && players[i].countCards("he") > 0) return true;
                }
                return false;
              },
              content: function() {
                "step 0"
                player.chooseTarget("探敌：选择一名角色，弃置其一张牌", function(card, player, target) {
                  return player != target && target.countCards("hej") > 0;
                }, false).ai = function(target) {
                  var att = get.attitude(player, target);
                  var nh = target.countCards('h');
                  if (att > 0) {
                    var js = target.getCards('j');
                    if (js.length) {
                      var jj = js[0].viewAs ? {
                        name: js[0].viewAs
                      } : js[0];
                      if (jj.name == 'guohe' || js.length > 1 || get.effect(target, jj, target, player) < 0) {
                        return 3;
                      }
                    }
                    if (target.getEquip('baiyin') && target.isDamaged() &&
                      get.recoverEffect(target, player, player) > 0) {
                      if (target.hp == 1 && !target.hujia) return 1.6;
                      if (target.hp == 2) return 0.01;
                      return 0;
                    }
                    return -1.5;
                  }
                  var es = target.getCards('e');
                  var noe = (es.length == 0 || target.hasSkillTag('noe'));
                  var noe2 = (es.filter(function(esx) {
                    return get.value(esx, target) > 0;
                  }).length == 0);
                  var noh = (nh == 0 || target.hasSkillTag('noh'));
                  if (noh && (noe || noe2)) return 0;
                  if (att <= 0 && !target.countCards('he')) return -1.5;
                  return 1.5;
                }
                "step 1"
                if (result.bool) {
                  player.storage.tandi3d8 = 1;
                  player.discardPlayerCard(1, result.targets[0], 'hej');
                } else event.finish();
                "step 2"
                if (result.bool && player.storage.tandi3d8 == 1) {
                  player.storage.tandi3d8 = 0;
                  trigger.cancel();
                } else {
                  player.storage.tandi3d8 = 0;
                  event.finish();
                }
              },
              group: ["tandi3d8_phase", "tandi3d8_use", "tandi3d8_start"],
              subSkill: {
                phase: {
                  audio: "xinfu_dianhu",
                  trigger: {
                    player: "phaseUseBefore",
                  },
                  filter: function(event, player) {
                    if (player.storage.tandi3d8 != 0) return false;
                    var players = game.filterPlayer();
                    for (var i = 0; i < players.length; i++) {
                      if (players[i] != player && players[i].countCards("hej") > 0) return true;
                    }
                    return false;
                  },
                  check: function(event, player) {
                    var players = game.filterPlayer();
                    for (var i = 0; i < players.length; i++) {
                      if (players[i] == player) continue;
                      var att = get.attitude(player, players[i]);
                      if (att > 0 && players[i].countCards("j") > 0) return true;
                      if (att < 0 && players[i].countCards("he") > 0) return true;
                    }
                    return false;
                  },
                  content: function() {
                    "step 0"
                    player.chooseTarget("探敌：选择一名角色，弃置其一张牌", function(card, player, target) {
                      return player != target && target.countCards("hej") > 0;
                    }, false).ai = function(target) {
                      if (player.storage.tandi3d8_first != player && player.storage.tandi3d8_first == target) return 0;
                      var att = get.attitude(player, target);
                      var nh = target.countCards('h');
                      if (att > 0) {
                        var js = target.getCards('j');
                        if (js.length) {
                          var jj = js[0].viewAs ? {
                            name: js[0].viewAs
                          } : js[0];
                          if (jj.name == 'guohe' || js.length > 1 || get.effect(target, jj, target, player) < 0) {
                            return 3;
                          }
                        }
                        if (target.getEquip('baiyin') && target.isDamaged() &&
                          get.recoverEffect(target, player, player) > 0) {
                          if (target.hp == 1 && !target.hujia) return 1.6;
                          if (target.hp == 2) return 0.01;
                          return 0;
                        }
                        return -1.5;
                      }
                      var es = target.getCards('e');
                      var noe = (es.length == 0 || target.hasSkillTag('noe'));
                      var noe2 = (es.filter(function(esx) {
                        return get.value(esx, target) > 0;
                      }).length == 0);
                      var noh = (nh == 0 || target.hasSkillTag('noh'));
                      if (noh && (noe || noe2)) return 0;
                      if (att <= 0 && !target.countCards('he')) return -1.5;
                      return 1.5;
                    }
                    "step 1"
                    if (result.bool) {
                      player.storage.tandi3d8 = 2;
                      player.discardPlayerCard(1, result.targets[0], 'hej');
                    } else event.finish();
                    "step 2"
                    if (result.bool && player.storage.tandi3d8 == 2) {
                      player.storage.tandi3d8 = 0;
                      trigger.cancel();
                    } else {
                      player.storage.tandi3d8 = 0;
                      event.finish();
                    }
                  },
                  sub: true,
                },
                use: {
                  trigger: {
                    global: "loseEnd",
                  },
                  filter: function(event, player) {
                    if (!event.parent || !event.parent.parent || !event.parent.parent.parent) return false;
                    var evt = event.parent.parent.parent;
                    if (evt.name != 'tandi3d8' && evt.name != 'tandi3d8_phase') return false;
                    if (player.storage.tandi3d8 != 1 && player.storage.tandi3d8 != 2) return false;
                    return true;
                  },
                  check: function(event, player) {
                    var att = get.attitude(player, event.player);
                    if (att >= 0) return true;
                    var status = 0;
                    if (player.storage.tandi3d8 == 1) {
                      if (player.hp <= 2 && player.hp + player.countCards("h") <= 4) status = 1;
                      else status = 2;
                    } else if (player.storage.tandi3d8 == 2) {
                      var cards = player.getCards("h");
                      var count = 0;
                      var count1 = 0;
                      var count2 = 0;
                      var equip = 0;
                      for (var i = 0; i < cards.length; i++) {
                        var effect = player.getUseValue({
                          name: cards[i].name
                        });
                        if (effect > 12) count += 1;
                        if (effect > 5) count2 += 1;
                        if (get.value(cards[i]) >= 8) count1 += 1;
                        if (get.subtype(cards[i]) == 'equip2' && (!player.getEquip(2) || get.value(player.getEquip(2)) < get.value(cards[i]))) {
                          equip = 1;
                        }
                        if (get.subtype(cards[i]) == 'equip3' && !player.getEquip(3)) {
                          equip = 1;
                        }
                        if (get.subtype(cards[i]) == 'equip1' && !player.getEquip(1)) {
                          equip = 1;
                        }
                        if (get.subtype(cards[i]) == 'equip4' && !player.getEquip(4)) {
                          equip = 1;
                        }
                        if (get.subtype(cards[i]) == 'equip5' && !player.getEquip(5)) {
                          equip = 1;
                        }
                      }
                      if ((player.hp <= 2 && player.countCards("h") - player.hp >= 2) || count > 1 || count1 > player.hp || equip == 1) status = 3;
                      else if (count2 > 0) status = 4;
                      else status = 5;
                    }
                    if (status == 5) return false;
                    if (status == 1 || status == 3) return true;
                    if (get.type(event.cards[0]) == 'equip') {
                      if (get.subtype(event.cards[0]) == 'equip2' || get.subtype(event.cards[0]) == 'equip3') {
                        if (event.player.hp <= 2) return false;
                        return Math.random() > 0.7;
                      }
                      if (get.subtype(event.cards[0]) == 'equip1' || get.subtype(event.cards[0]) == 'equip4' || get.subtype(event.cards[0]) == 'equip5') {
                        if (event.player.countCards("h") > 3) return false;
                        return Math.random() > 0.7;
                      }
                      return true;
                    } else if (get.type(event.cards[0]) == 'basic') {
                      if (event.cards[0].name == 'du') return true;
                      if (event.cards[0].name == 'tao') return false;
                      if (event.cards[0].name == 'shan') {
                        if (event.player.countCards("h") == 0 && event.player.hp <= 2) return false;
                        if (event.player.countCards("h") <= 1 || event.player.hp <= 1) return Math.random() > 0.8;
                        return Math.random() > 0.4;
                      }
                      if (event.cards[0].name == 'jiu') {
                        if (event.player.countCards("h") == 0 && event.player.hp == 1) return false;
                        return true;
                      }
                      return true;
                    } else if (get.type(event.cards[0]) == 'trick' || get.type(event.cards[0]) == 'delay') {
                      if (get.value(event.cards[0]) >= 8) return false;
                      else if (get.value(event.cards[0]) >= 6) return Math.random() > 0.5;
                      return true;
                    }
                    return true;
                  },
                  prompt2: function(event, player) {
                    return '是否令' + get.translation(event.player) + '收回' + get.translation(event.cards) + '？';
                  },
                  content: function() {
                    trigger.player.gain(trigger.cards, "gain2");
                    if (player.storage.tandi3d8 == 1 && trigger.player.countCards("h") == 1) player.storage.tandi3d8_first = trigger.player;
                    player.storage.tandi3d8 = 0;
                  },
                },
                start: {
                  trigger: {
                    player: "phaseBefore",
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    player.storage.tandi3d8 = 0;
                    player.storage.tandi3d8_first = player;
                  },
                  sub: true,
                },
                buff: {
                  mod: {},
                  ai: {
                    effect: {
                      target: function(card, player, target, current) {
                        if (get.type(card) != 'delay') return;
                        var current = player;
                        while (current != target) {
                          if (get.attitude(current, target) > 0 && current.hasSkill("tandi3d8")) return 'zeroplayertarget';
                          current = current.next;
                        }
                        return;
                      },
                    },
                  },
                },
              },
              ai: {
                expose: 0.2,
              },
            },

            qiahua3d8: {
              audio: "jlsg_cangshu",
              group: ["qiahua3d82"],
              init: function(player) {
                player.storage.qiahua3d8 = [];
              },
              trigger: {
                global: "phaseBegin",
              },
              filter: function(event, player) {
                var num = player.countCards('h') - player.storage.qiahua3d8.length;
                return num >= event.player.hp && event.player != player;
              },
              check: function(event, player) {
                return get.attitude(player, event.player) > 0 && !event.player.hasSkill("xunxun");
              },
              content: function() {
                'step 0'
                var check = true;
                player.chooseCard(trigger.player.hp, 'h', '洽化：是否明置手牌令' + get.translation(trigger.player) + '获得【恂恂】？', function(card, player) {
                  if (player.storage.qiahua3d8) return !player.storage.qiahua3d8.contains(card);
                  else return true;
                }).set('ai', function(card) {
                  return 10 - get.value(card);
                });
                'step 1'
                if (result.bool) {
                  //player.logSkill('qiahua3d8',trigger.player);
                  player.showCards(result.cards);
                  player.storage.qiahua3d8 = player.storage.qiahua3d8.concat(result.cards);
                  player.syncStorage('qiahua3d8');
                  player.markSkill('qiahua3d8');
                  trigger.player.addTempSkill("xunxun", "phaseAfter");
                }
              },
              marktext: "明",
              intro: {
                mark: function(dialog, content, player) {
                  var hs = player.storage.qiahua3d8;
                  if (hs.length) {
                    dialog.add('<div class="text center">' + get.translation(player) + '明置的牌</div>');
                    dialog.addSmall(hs);
                  } else {
                    dialog.addText('无明置手牌');
                  }
                },
                content: function(content, player) {
                  var hs = player.storage.qiahua3d8;
                  if (hs.length) {
                    return get.translation(hs);
                  } else {
                    return '无明置手牌';
                  }
                },
              },
            },

            "qiahua3d82": {
              trigger: {
                player: "loseEnd",
              },
              forced: true,
              silent: true,
              content: function() {
                if (player.storage.qiahua3d8) {
                  for (var i = 0; i < player.storage.qiahua3d8.length; i++) {
                    if (trigger.cards.contains(player.storage.qiahua3d8[i])) {
                      player.storage.qiahua3d8.splice(i--, 1);
                    }
                  }
                }
                if (player.storage.qiahua3d8.length == 0) player.unmarkSkill('qiahua3d8');
                player.updateMarks();
              },
              popup: false,
            },

            "qiahua3d83": {
              trigger: {
                target: ["rewriteGainResult", "rewriteDiscardResult"],
              },
              forced: true,
              silent: true,
              filter: function(event, player) {
                if (!player.storage.qiahua3d8) return false;
                return event.player != player && player.countCards('he');
              },
              content: function() {
                'step 0'
                if (!player.storage.qiahua3d82) player.storage.qiahua3d82 = [];
                player.storage.qiahua3d82 = player.storage.qiahua3d82.concat(player.getCards('h'));
                if (player.storage.qiahua3d8) {
                  for (var i = 0; i < player.storage.qiahua3d82.length; i++) {
                    if (player.storage.qiahua3d8.contains(player.storage.qiahua3d82[i])) {
                      player.storage.qiahua3d82.splice(i--, 1);
                    }
                  }
                }
                var info = ['请选择需要弃置或获得的牌'];
                if (player.storage.qiahua3d8) {
                  info.push('<div class="text center">' + get.translation(player) + '明置的手牌</div>');
                  info.push(player.storage.qiahua3d8);
                }
                if (player.storage.qiahua3d82.length > 0) {
                  info.push('<div class="text center">' + get.translation(player) + '其余的手牌</div>');
                  info.push([player.storage.qiahua3d82, 'blank']);
                }
                if (player.countCards('e')) {
                  info.push('<div class="text center">' + get.translation(player) + '的装备区</div>');
                  info.push(player.getCards('e'));
                }
                var next = trigger.player.chooseButton();
                next.set('createDialog', info);
                next.set('ai', function(button) {
                  return get.value(button.link);
                });
                next.filterButton = trigger.filterButton;
                next.selectButton = trigger.result.cards.length;
                'step 1'
                if (result.bool) {
                  delete player.storage.qiahua3d82;
                  trigger.result.cards = result.links;
                  trigger.result.links = result.links;
                  trigger.cards = result.links;
                  trigger.untrigger();
                }
              },
              popup: false,
            },

            fusi3d8: {
              audio: "jlsg_kanwu",
              forced: true,
              mod: {
                ignoredHandcard: function(card, player) {
                  if (player.storage.qiahua3d8 && player.storage.qiahua3d8.contains(card)) {
                    return true;
                  }
                },
                cardDiscardable: function(card, player, name) {
                  if (name == 'phaseDiscard' && player.storage.qiahua3d8 && player.storage.qiahua3d8.contains(card)) return false;
                },
              },
              global: ["fusi3d8_response", "fusi3d8_debuff"]
              //global:["fusi3d8_response"],
            },

            fusi3d8_debuff: {
              forced: true,
              mod: {
                cardEnabled: function(card, player) {
                  if (!_status.currentPhase.hasSkill("fusi3d8")) return;
                  if (player.hasSkill("fusi3d8")) return;
                  if (!_status.currentPhase.storage.qiahua3d8 ||
                    _status.currentPhase.storage.qiahua3d8.length != _status.currentPhase.countCards("h")) return;
                  if (player.getCards("h").contains(card)) return false;
                  return;
                },
                cardUsable: function(card, player) {
                  if (!_status.currentPhase.hasSkill("fusi3d8")) return;
                  if (player.hasSkill("fusi3d8")) return;
                  if (!_status.currentPhase.storage.qiahua3d8 ||
                    _status.currentPhase.storage.qiahua3d8.length != _status.currentPhase.countCards("h")) return;
                  if (player.getCards("h").contains(card)) return false;
                  return;
                },
                cardRespondable: function(card, player) {
                  if (!_status.currentPhase.hasSkill("fusi3d8")) return;
                  if (player.hasSkill("fusi3d8")) return;
                  if (!_status.currentPhase.storage.qiahua3d8 ||
                    _status.currentPhase.storage.qiahua3d8.length != _status.currentPhase.countCards("h")) return;
                  if (player.getCards("h").contains(card)) return false;
                  return;
                },
                cardSavable: function(card, player) {
                  if (!_status.currentPhase.hasSkill("fusi3d8")) return;
                  if (player.hasSkill("fusi3d8")) return;
                  if (!_status.currentPhase.storage.qiahua3d8 ||
                    _status.currentPhase.storage.qiahua3d8.length != _status.currentPhase.countCards("h")) return;
                  if (player.getCards("h").contains(card)) return false;
                  return;
                },
              },
            },

            fusi3d8_use: {
              audio: "jlsg_kanwu",
              enable: "phaseUse",
              filter: function(event, player) {
                if (player.hasSkill("fusi3d8")) return false;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i] != player && players[i].storage.qiahua3d8 && players[i].storage.qiahua3d8.length > 0 &&
                    players[i].hasSkill("fusi3d8") && players[i].storage.qiahua3d8.length == players[i].countCards('h')) return true;
                }
                return false;
              },
              filterTarget: function(card, player, target) {
                return target != player && target.storage.qiahua3d8 && target.storage.qiahua3d8.length > 0 && target.hasSkill("fusi3d8") &&
                  target.storage.qiahua3d8.length == target.countCards('h');
              },
              content: function() {
                'step 0'
                player.chooseButton(['腹笥:选择一张明置牌使用之', target.storage.qiahua3d8], false)
                  .set('filterButton', function(button) {
                    var card = button.link;
                    if (card.name == 'sha' && player.getCardUsable('sha') == 0) {
                      return false;
                    };
                    var players = game.filterPlayer();
                    for (var i = 0; i < players.length; i++) {
                      if (player.canUse(button.link, players[i])) return true;
                    }
                    return false;
                  })
                  .set('ai', function(button) {
                    return get.value(button.link);
                  });

                "step 1"
                if (result.bool) {
                  target.lose(result.links[0], ui.special);
                  target.storage.qiahua3d8.remove(result.links[0]);
                  game.log(player, "决定使用", target, "的明置牌", result.links[0]);
                  player.chooseUseTarget(result.links[0], false, true);
                  target.logSkill("tuoji3d8");
                  target.draw(2);
                } else {
                  game.log(player, "没有使用", target, "的明置牌");
                  event.finish();
                }
              },
              ai: {},
            },

            fusi3d8_response: {
              enable: ["chooseToUse", "chooseToRespond"],
              hiddenCard: function(player, name) {
                if (player.hasSkill("fusi3d8")) return false;
                var event = _status.event;
                if (event.parent.name == 'phaseUse') {
                  var players = game.filterPlayer();
                  for (var i = 0; i < players.length; i++) {
                    if (players[i] != player && players[i].storage.qiahua3d8 && players[i].storage.qiahua3d8.length > 0 &&
                      players[i].hasSkill("fusi3d8") && players[i].storage.qiahua3d8.length == players[i].countCards('h')) {
                      var cards = players[i].storage.qiahua3d8;
                      var flag = 0;
                      for (var j = 0; j < cards.length; j++) {
                        var card = cards[j];
                        if (card.name == 'sha' && player.getCardUsable('sha') == 0) continue;
                        for (var k = 0; k < players.length; k++) {
                          if (player.canUse(card, players[k])) flag = 1;
                        }
                      }
                      if (flag == 1) return true;
                    }
                  }
                  return false;
                }
                if (event.responded) return false;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i] != player && players[i].storage.qiahua3d8 && players[i].storage.qiahua3d8.length > 0 &&
                    players[i].hasSkill("fusi3d8") && players[i].storage.qiahua3d8.length == players[i].countCards('h')) {
                    var cards = players[i].storage.qiahua3d8;
                    for (var j = 0; j < cards.length; j++) {
                      if (get.type(cards[j]) != 'basic') return false;
                      if (event.filterCard({
                          name: cards[j].name
                        }, player, event)) return true;
                    }
                  }
                }
                return false;
              },
              filter: function(event, player) {
                if (player.hasSkill("fusi3d8")) return false;
                if (event.parent.name == 'phaseUse') {
                  var players = game.filterPlayer();
                  for (var i = 0; i < players.length; i++) {
                    if (players[i] != player && players[i].storage.qiahua3d8 && players[i].storage.qiahua3d8.length > 0 &&
                      players[i].hasSkill("fusi3d8") && players[i].storage.qiahua3d8.length == players[i].countCards('h')) {
                      var cards = players[i].storage.qiahua3d8;
                      var flag = 0;
                      for (var j = 0; j < cards.length; j++) {
                        var card = cards[j];
                        if (card.name == 'sha' && player.getCardUsable('sha') == 0) continue;
                        for (var k = 0; k < players.length; k++) {
                          if (player.canUse(card, players[k])) flag = 1;
                        }
                      }
                      if (flag == 1) return true;
                    }
                  }
                  return false;
                }
                if (event.responded) return false;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i] != player && players[i].storage.qiahua3d8 && players[i].storage.qiahua3d8.length > 0 &&
                    players[i].hasSkill("fusi3d8") && players[i].storage.qiahua3d8.length == players[i].countCards('h')) {
                    var cards = players[i].storage.qiahua3d8;
                    for (var j = 0; j < cards.length; j++) {
                      if (get.type(cards[j]) != 'basic') return false;
                      if (event.filterCard({
                          name: cards[j].name
                        }, player, event)) return true;
                    }
                  }
                }
                return false;
              },
              delay: false,
              content: function() {
                'step 0'
                player.chooseTarget('选择一名拥有【腹笥】的角色', function(card, player, target) {
                  var evt = event.getParent(3);
                  var players = game.filterPlayer();
                  if (target == player) return false;
                  if (evt.name == 'phaseUse') {
                    if (target != player && target.storage.qiahua3d8 && target.storage.qiahua3d8.length > 0 && target.hasSkill("fusi3d8") &&
                      target.storage.qiahua3d8.length == target.countCards('h')) {
                      var cards = target.storage.qiahua3d8;
                      var flag = 0;
                      for (var j = 0; j < cards.length; j++) {
                        var card = cards[j];
                        if (card.name == 'sha' && player.getCardUsable('sha') == 0) continue;
                        for (var k = 0; k < players.length; k++) {
                          if (player.canUse(card, players[k])) flag = 1;
                        }
                      }
                      if (flag == 1) return true;
                    }
                    return false;
                  }

                  if (target != player && target.storage.qiahua3d8 && target.storage.qiahua3d8.length > 0 && target.hasSkill("fusi3d8") &&
                    target.storage.qiahua3d8.length == target.countCards('h')) {
                    var cards = target.storage.qiahua3d8;
                    var flag = 0;
                    var evt = event.getParent(2);
                    for (var j = 0; j < cards.length; j++) {
                      var card = cards[j];
                      if (get.type(cards[j]) != 'basic') return false;
                      if (evt.filterCard({
                          name: cards[j].name
                        }, player, event)) flag = 1;
                    }
                    if (flag == 1) return true;
                  }

                  return false;

                }).ai = function(target) {
                  if (target.hasSkill("tuoji3d8")) return get.attitude(player, target) + 10;
                  return -get.attitude(player, target) + 10;
                }

                'step 1'

                if (result.bool) {
                  event.target = result.targets[0];
                  game.log(player, "选择了", result.targets[0]);
                  player.line(result.targets, 'red');
                  event.target = result.targets[0];
                  var evt = event.getParent(2);
                  player.chooseButton(['腹笥：选择要' + (evt.name == 'chooseToUse' ? '使用' : '打出') + '的牌', result.targets[0].storage.qiahua3d8]).set('filterButton', function(button) {
                    var evt_1 = event.getParent(3);
                    var players = game.filterPlayer();
                    var card = button.link;
                    if (evt_1.name == 'phaseUse') {
                      if (card.name == 'sha' && player.getCardUsable('sha') == 0) return false;
                      var flag = 0;
                      for (var k = 0; k < players.length; k++) {
                        if (player.canUse(card, players[k])) flag = 1;
                      }
                      if (flag == 1) return true;
                      return false;
                    }
                    if (get.type(button.link) != 'basic') return false;
                    return evt.filterCard({
                      name: button.link.name
                    }, player, event);

                  }).set('ai', function(button) {
                    var evt_1 = event.getParent(3);
                    if (evt_1.name == 'phaseUse') {
                      return player.getUseValue({
                        name: button.link.name
                      });
                    }
                    return 1;
                  });
                } else event.finish();

                'step 2'

                if (result.bool && result.links && result.links.length) {
                  var evt = event.getParent(2);
                  if (event.getParent(3).name == 'phaseUse') {
                    event.target.lose(result.links[0], ui.special);
                    event.target.storage.qiahua3d8.remove(result.links[0]);
                    game.log(player, "决定使用", event.target, "的明置牌", result.links[0]);
                    player.chooseUseTarget(result.links[0], false, true);
                    if (event.target.hasSkill("tuoji3d8")) {
                      event.target.logSkill("tuoji3d8");
                      event.target.draw(2);
                    }
                  } else if (evt.name == 'chooseToUse') {
                    event.target.lose(result.links[0], ui.special);
                    event.target.storage.qiahua3d8.remove(result.links[0]);
                    game.broadcastAll(function(result) {
                      lib.skill.hx_fusi3d8_response_backup.viewAs = {
                        name: result.name,
                        cards: [result],
                        isCard: true
                      };
                      lib.skill.hx_fusi3d8_response_backup.prompt = '选择' + get.translation(result) + '的目标';
                    }, result.links[0]);
                    game.log(player, "选择使用", event.target, "的明置牌", result.links[0]);
                    evt.set('_backupevent', 'hx_fusi3d8_response_backup');
                    evt.backup('hx_fusi3d8_response_backup');
                    if (event.target.hasSkill("tuoji3d8")) {
                      event.target.logSkill("tuoji3d8");
                      event.target.draw(2);
                    }
                  } else {
                    delete evt.result.skill;
                    delete evt.result.used;
                    event.target.lose(result.links[0], ui.special);
                    event.target.storage.qiahua3d8.remove(result.links[0]);
                    evt.result.card = get.autoViewAs(result.links[0]);
                    game.log(player, "选择打出", event.target, "的明置牌", result.links[0]);
                    evt.result.cards = [result.links[0]];
                    evt.redo();
                    if (event.target.hasSkill("tuoji3d8")) {
                      event.target.logSkill("tuoji3d8");
                      event.target.draw(2);
                    }
                    return;
                  }
                } else {
                  game.log(player, "没有打出", event.target, "的明置牌");
                }
                var evt = event.getParent(2);
                evt.goto(0);
              },
              ai: {
                effect: {
                  target: function(card, player, target, effect) {
                    if (get.tag(card, 'respondShan')) return 0.7;
                    if (get.tag(card, 'respondSha')) return 0.7;
                  },
                },
                order: 11,
                respondShan: true,
                respondSha: true,
                result: {
                  player: function(player) {
                    if (_status.event.dying) return get.attitude(player, _status.event.dying);
                    var event = _status.event;
                    if (event.parent.name == 'phaseUse') {
                      var players = game.filterPlayer();
                      for (var i = 0; i < players.length; i++) {
                        if (players[i] != player && players[i].storage.qiahua3d8 && players[i].storage.qiahua3d8.length > 0 &&
                          players[i].hasSkill("fusi3d8") && players[i].storage.qiahua3d8.length == players[i].countCards('h')) {
                          var cards = players[i].storage.qiahua3d8;
                          var flag = 0;
                          for (var j = 0; j < cards.length; j++) {
                            var card = cards[j];
                            if (card.name == 'sha' && player.getCardUsable('sha') == 0) continue;
                            for (var k = 0; k < players.length; k++) {
                              if (player.canUse(card, players[k]) && player.getUseValue({
                                  name: card.name
                                }) > 0) flag = 1;
                            }
                          }
                          if (flag == 1) return 1;
                        }
                      }
                      return -1;
                    }
                    if (_status.event.dying) return get.attitude(player, _status.event.dying);
                    return 1;
                  },
                },
              },
            },

            "hx_fusi3d8_response_backup": {
              sourceSkill: 'hx_fusi3d8_response',
              precontent: function() {
                delete event.result.skill;
                event.result.cards = event.result.card.cards;
                event.result.card = get.autoViewAs(event.result.cards[0]);
              },
              filterCard: function() {
                return false
              },
              selectCard: -1,
            },

            tuoji3d8: {
              audio: "jlsg_kanwu",
            },

            diedang3d8: {
              enable: "phaseUse",
              usable: 1,
              audio: "nzry_zhizheng",
              init: function(player, skill) {
                player.storage[skill] = true;
              },
              mark: true,
              intro: {
                content: function(n, p, s) {
                  var a = p.storage[s];
                  var f = function(a) {
                    return a ? "摸" : "弃置"
                  };
                  return "出牌阶段限一次，你可以" + f(a) + "三张牌，然后" + f(!a) + "一张牌。";
                },
              },
              f: function() {
                var p = get.player();
                return p.storage.diedang3d8;
              },
              selectCard: function() {
                return lib.skill.diedang3d8.f() ? 0 : 3;
              },
              position: "he",
              filterCard: true,
              check: function(card) {
                if (lib.skill.gzdiedangx.f()) return 1;
                return 8 - get.value(card);
              },
              content: function() {
                "step 0"
                var b = lib.skill.diedang3d8.f();
                player.storage.diedang3d8 = !player.storage.diedang3d8;
                player.draw(b ? 3 : 1);
                if (b) player.chooseToDiscard("he", true);
              },
              ai: {
                order: function() {
                  if (lib.skill.diedang3d8.f()) return 6;
                  return 1;
                },
                result: {
                  player: function(player, target) {
                    if (lib.skill.diedang3d8.f()) return player.maxHp - player.countCards("h");
                    return player.needsToDiscard() || player.countCards("he") - player.hp - 1.9;
                  },
                },
              },
            },

            anliu3d8: {
              trigger: {
                player: 'phaseEnd'
              },
              audio: "nzry_kuizhu",
              filter: function(event, player) {
                if (!player.countCards("h")) return false;
                return game.hasPlayer(function(current) {
                  if (player == current) return false;
                  return current.countCards("h");
                });
              },
              check: function(event, player) {
                return player.hasFriend();
              },
              content: function() {
                'step 0'
                player.chooseTarget(get.prompt2('anliu3d8'), true, function(card, player, target) {
                  return target != player && target.countCards('h');
                }).set('ai', function(target) {
                  var att = get.attitude(_status.event.player, target);
                  if (player.isDamaged()) {
                    return att * target.countCards('h');
                  }
                  return att;
                });
                'step 1'
                if (result.bool) {
                  event.target = result.targets[0];
                  player.chooseCard('he', true).ai = function(card) {
                    if (player.isDamaged()) {
                      if (get.color(card) == 'red') return 20 - get.value(card);
                      return 10 - get.value(card);
                    }
                    if (get.color(card) == 'black') return 20 - get.value(card);
                    return 10 - get.value(card);
                  };

                }
                'step 2'
                if (result.bool) {　　
                  event.cardp = result.cards[0];
                  event.target.chooseCard('he', true).ai = function(card) {
                    if (player.isDamaged()) {
                      if (get.color(card) == 'red') return 20 - get.value(card);
                      return 10 - get.value(card);
                    }
                    if (get.color(card) == 'black') return 20 - get.value(card);
                    return 10 - get.value(card);
                  };
                }
                'step 3'
                if (result.bool) {
                  event.cardt = result.cards[0];
                  player.showCards(event.cardp);
                  event.target.showCards(event.cardt);
                }
                'step 4'
                player.$giveAuto(event.cardp, event.target);
                event.target.gain(event.cardp, player);
                event.target.give(event.cardt, player);
                'step 5'
                var colorp = get.color(event.cardp);
                var colort = get.color(event.cardt);
                if (colort == 'red' && colorp == 'red') {
                  player.recover();
                }
                if (colort == 'black' && colorp == 'black') {
                  event.target.draw(2);
                }　　　　　　　　　　
              },
            },

            kewu3d8: {
              audio: "diancai",
              init: function(player) {
                player.storage.kewu3d8_basic = 0;
                player.storage.kewu3d8_trick = 0;
                player.storage.kewu3d8_equip = 0;
                player.storage.kewu3d8 = 0;
              },
              trigger: {
                player: "phaseDiscardBefore",
              },
              filter: function(event, player) {
                return player.storage.kewu3d8 == 0 && player.storage.kewu3d8_basic <= 1 && player.storage.kewu3d8_trick <= 1 && player.storage.kewu3d8_equip <= 1;
              },
              frequent: true,
              content: function() {
                trigger.cancel();
              },
              group: ["kewu3d8_start", "kewu3d8_use", "kewu3d8_new"],
              subSkill: {
                start: {
                  trigger: {
                    player: "phaseBegin",
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    player.storage.kewu3d8_basic = 0;
                    player.storage.kewu3d8_trick = 0;
                    player.storage.kewu3d8_equip = 0;
                    player.storage.kewu3d8 = 0;
                    if (trigger.skill && trigger.skill == "kewu3d8_new") player.storage.kewu3d8 = 1;
                  },
                  sub: true,
                },
                use: {
                  trigger: {
                    player: "useCard",
                  },
                  filter: function(event, player) {
                    return player.isPhaseUsing() && player.storage.kewu3d8 == 0;
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    var type = get.type(trigger.card, 'trick');
                    if (type == 'basic') player.storage.kewu3d8_basic += 1;
                    if (type == 'trick') player.storage.kewu3d8_trick += 1;
                    if (type == 'equip') player.storage.kewu3d8_equip += 1;
                  },
                  sub: true,
                },
                new: {
                  audio: "diaodu",
                  trigger: {
                    player: "phaseAfter",
                  },
                  filter: function(event, player) {
                    return player.storage.kewu3d8 == 0 && player.storage.kewu3d8_basic >= 1 && player.storage.kewu3d8_trick >= 1 && player.storage.kewu3d8_equip >= 1;
                  },
                  frequent: true,
                  content: function() {
                    player.storage.kewu3d8 = 1;
                    player.insertPhase();
                  },
                  sub: true,
                },
              },
              ai: {
                expose: 0.2,
                threaten: 0.8,
                effect: {
                  player: function(card, player, target, current) {
                    if (!player.isPhaseUsing()) return;
                    var type = get.type(card, "trick");
                    var bc = player.storage.kewu3d8_basic;
                    var tc = player.storage.kewu3d8_trick;
                    var ec = player.storage.kewu3d8_equip;
                    if (player.storage.kewu3d8 == 0) {
                      if (player.countCards("h") > player.getHandcardLimit() + 1) {
                        var count = player.countCards("h") - player.getHandcardLimit() - 1;
                        if (bc == 1 && tc <= 1 && ec <= 1 && type == 'basic') return [1, -count];
                        if (bc <= 1 && tc == 1 && ec <= 1 && type == 'trick') return [1, -count];
                        if (bc <= 1 && tc <= 1 && ec == 1 && type == 'equip') return [1, -count];
                      } else if (bc == 0 && tc >= 1 && ec >= 1 && type == 'basic') return [1, 3];
                      else if (bc >= 1 && tc == 0 && ec >= 1 && type == 'trick') return [1, 3];
                      else if (bc >= 1 && tc >= 1 && ec == 0 && type == 'equip') return [1, 3];
                      else if (player.countCards("h") <= player.getHandcardLimit()) return [1, -3];
                    } else if (player.countCards("h") <= player.getHandcardLimit()) return [1, -3];
                  },
                }
              },
            },

            jingxuan3d8: {
              audio: "jlsg_lirang",
              trigger: {
                player: "useCardEnd",
              },
              filter: function(event, player) {
                return player.isPhaseUsing();
              },
              frequent: true,
              content: function() {
                'step 0'
                var topcard = ui.cardPile.childNodes[0]; //get.cards(1)[0];
                player.showCards(topcard);
                var type1 = get.type(topcard, "trick");
                var type2 = get.type(trigger.card, "trick");
                if (type1 != type2) event.finish();
                else {
                  player.chooseToDiscard("是否重铸一张手牌?", 1, 'h', false).ai = function(card) {
                    if (card.name == 'du' && player.hp <= 2) return 0;
                    return get.value(topcard) - get.value(card);
                  };
                }
                'step 1'
                if (result.bool) {
                  player.draw();
                }
              },
            },

            kenjian3d8: {
              audio: "jlsg_xianshi",
              trigger: {
                global: ["loseAfter", "cardsDiscardAfter"],
              },
              init: function(player) {
                player.storage.kenjian3d8_equip1 = 0;
                player.storage.kenjian3d8_equip2 = 0;
                player.storage.kenjian3d8_equip3 = 0;
                player.storage.kenjian3d8_equip4 = 0;
                player.storage.kenjian3d8_equip5 = 0;
              },
              filter: function(event, player) {
                if(event.parent.name == 'equip') return false;
                if (!event.cards || event.cards.filter(function(card) {
                    return get.position(card, true) == 'd' && get.type(card) == 'equip';
                  }).length == 0) return false;
                var cards = event.cards.filter(function(card) {
                  return get.position(card, true) == 'd' && get.type(card) == 'equip';
                });
                var c1 = 0;
                var c2 = 0;
                var c3 = 0;
                var c4 = 0;
                var c5 = 0;
                for (var i = 0; i < cards.length; i++) {
                  var card = cards[i];
                  if (get.subtype(card, false) == 'equip1') c1 += 1;
                  if (get.subtype(card, false) == 'equip2') c2 += 1;
                  if (get.subtype(card, false) == 'equip3') c3 += 1;
                  if (get.subtype(card, false) == 'equip4') c4 += 1;
                  if (get.subtype(card, false) == 'equip5') c5 += 1;
                }
                if (c1 > 0 && c1 == player.storage.kenjian3d8_equip1 && !_status.currentPhase.getEquip(1)) return true;
                if (c2 > 0 && c2 == player.storage.kenjian3d8_equip2 && !_status.currentPhase.getEquip(2)) return true;
                if (c3 > 0 && c3 == player.storage.kenjian3d8_equip3 && !_status.currentPhase.getEquip(3)) return true;
                if (c4 > 0 && c4 == player.storage.kenjian3d8_equip4 && !_status.currentPhase.getEquip(4)) return true;
                if (c5 > 0 && c5 == player.storage.kenjian3d8_equip5 && !_status.currentPhase.getEquip(5)) return true;
                return false;
              },
              check: function(event, player) {
                var cards = event.cards.filter(function(card) {
                  return get.position(card, true) == 'd' && get.type(card) == 'equip';
                });
                var c1 = 0;
                var c2 = 0;
                var c3 = 0;
                var c4 = 0;
                var c5 = 0;
                for (var i = 0; i < cards.length; i++) {
                  var card = cards[i];
                  if (get.subtype(card, false) == 'equip1') c1 += 1;
                  if (get.subtype(card, false) == 'equip2') c2 += 1;
                  if (get.subtype(card, false) == 'equip3') c3 += 1;
                  if (get.subtype(card, false) == 'equip4') c4 += 1;
                  if (get.subtype(card, false) == 'equip5') c5 += 1;
                }
                if (c1 > 0 && c1 == player.storage.kenjian3d8_equip1 && !_status.currentPhase.getEquip(1)){
                  for (var i = 0; i < cards.length; i++) {
                    var card = cards[i];
                    if (get.subtype(card, false) == 'equip1'){
                      if(get.effect(_status.currentPhase, card, player, player)>0) return true;
                    }
                  }
                }
                if (c2 > 0 && c2 == player.storage.kenjian3d8_equip2 && !_status.currentPhase.getEquip(2)){
                  for (var i = 0; i < cards.length; i++) {
                    var card = cards[i];
                    if (get.subtype(card, false) == 'equip2'){
                      if(get.effect(_status.currentPhase, card, player, player)>0) return true;
                    }
                  }
                }
                if (c3 > 0 && c3 == player.storage.kenjian3d8_equip3 && !_status.currentPhase.getEquip(3)){
                  for (var i = 0; i < cards.length; i++) {
                    var card = cards[i];
                    if (get.subtype(card, false) == 'equip3'){
                      if(get.effect(_status.currentPhase, card, player, player)>0) return true;
                    }
                  }
                }
                if (c4 > 0 && c4 == player.storage.kenjian3d8_equip4 && !_status.currentPhase.getEquip(4)){
                  for (var i = 0; i < cards.length; i++) {
                    var card = cards[i];
                    if (get.subtype(card, false) == 'equip4'){
                      if(get.effect(_status.currentPhase, card, player, player)>0) return true;
                    }
                  }
                }
                if (c5 > 0 && c5 == player.storage.kenjian3d8_equip5 && !_status.currentPhase.getEquip(5)){
                  for (var i = 0; i < cards.length; i++) {
                    var card = cards[i];
                    if (get.subtype(card, false) == 'equip5'){
                      if(get.effect(_status.currentPhase, card, player, player)>0) return true;
                    }
                  }
                }
                return false;
              },
              content: function() {
                'step 0'
                var cards = trigger.cards.filter(function(card) {
                  return get.position(card, true) == 'd' && get.type(card) == 'equip';
                });
                var count = 0;
                event.candidates = [];
                event.index = 0;
                var c1 = 0;
                var c2 = 0;
                var c3 = 0;
                var c4 = 0;
                var c5 = 0;
                for (var i = 0; i < cards.length; i++) {
                  var card = cards[i];
                  if (get.subtype(card, false) == 'equip1') c1 += 1;
                  if (get.subtype(card, false) == 'equip2') c2 += 1;
                  if (get.subtype(card, false) == 'equip3') c3 += 1;
                  if (get.subtype(card, false) == 'equip4') c4 += 1;
                  if (get.subtype(card, false) == 'equip5') c5 += 1;
                }
                for (var i = 0; i < cards.length; i++) {
                  var card = cards[i];
                  if (get.subtype(card, false) == 'equip1' && c1 == player.storage.kenjian3d8_equip1 && !_status.currentPhase.getEquip(1)) event.candidates.add(cards[i]);
                  if (get.subtype(card, false) == 'equip2' && c2 == player.storage.kenjian3d8_equip2 && !_status.currentPhase.getEquip(2)) event.candidates.add(cards[i]);
                  if (get.subtype(card, false) == 'equip3' && c3 == player.storage.kenjian3d8_equip3 && !_status.currentPhase.getEquip(3)) event.candidates.add(cards[i]);
                  if (get.subtype(card, false) == 'equip4' && c4 == player.storage.kenjian3d8_equip4 && !_status.currentPhase.getEquip(4)) event.candidates.add(cards[i]);
                  if (get.subtype(card, false) == 'equip5' && c5 == player.storage.kenjian3d8_equip5 && !_status.currentPhase.getEquip(5)) event.candidates.add(cards[i]);
                }
                'step 1'
                event.player = _status.currentPhase;
                event.list = ['是', '否']
                player.chooseControl(event.list, true).set('prompt', '恳谏：是否将' + get.translation(event.candidates[event.index]) + '置于' + get.translation(event.player) + '的装备区？').ai = function() {
                  var card = event.candidates[event.index];
                  var sub = get.subtype(card);
                  var eff = get.effect(_status.currentPhase, card, player, player);
                  if(eff<=0) return '否';
                  for(var i = event.index;i<event.candidates.length;i++){
                    var card1 = event.candidates[i];
                    if(get.subtype(card1)!=sub) continue;
                    if(get.effect(_status.currentPhase, card1, player, player)>get.effect(_status.currentPhase, card, player, player)) return '否';
                  }
                  return '是';
                };
                'step 2'
                if (result.control == '是') {
                  event.player.equip(event.candidates[event.index]);
                }
                event.index += 1;
                while(event.index<event.candidates.length && event.player.getEquip(get.subtype(event.candidates[event.index]))){
                  event.index += 1;
                }
                if (event.index < event.candidates.length) event.goto(1);
                else event.finish();
              },
              group: ["kenjian3d8_start", "kenjian3d8_use"],
              subSkill: {
                start: {
                  trigger: {
                    global: "phaseBegin",
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    player.storage.kenjian3d8_equip1 = 0;
                    player.storage.kenjian3d8_equip2 = 0;
                    player.storage.kenjian3d8_equip3 = 0;
                    player.storage.kenjian3d8_equip4 = 0;
                    player.storage.kenjian3d8_equip5 = 0;
                  },
                  sub: true,
                },
                use: {
                  trigger: {
                    global: ["loseAfter", "cardsDiscardAfter"],
                  },
                  filter: function(event, player) {
                    if (!event.cards || event.cards.filter(function(card) {
                        return get.position(card, true) == 'd' && get.type(card) == 'equip';
                      }).length == 0) return false;
                    return true;
                  },
                  forced: true,
                  popup: false,
                  silent: true,
                  content: function() {
                    var cards = trigger.cards.filter(function(card) {
                      return get.position(card, true) == 'd' && get.type(card) == 'equip';
                    });
                    for (var i = 0; i < cards.length; i++) {
                      var card = cards[i];
                      if (get.subtype(card, false) == 'equip1') player.storage.kenjian3d8_equip1 += 1;
                      if (get.subtype(card, false) == 'equip2') player.storage.kenjian3d8_equip2 += 1;
                      if (get.subtype(card, false) == 'equip3') player.storage.kenjian3d8_equip3 += 1;
                      if (get.subtype(card, false) == 'equip4') player.storage.kenjian3d8_equip4 += 1;
                      if (get.subtype(card, false) == 'equip5') player.storage.kenjian3d8_equip5 += 1;
                    }
                  },
                  sub: true,
                },
              },
            },

            jianni3d8: {
              audio: "jlsg_hengshi",
              enable: "phaseUse",
              usable: 1,
              filter: function(event, player) {
                return game.hasPlayer(function(current) {
                  return player != current && get.distance(current, player, 'attack') <= 1 && current.countCards("hej") > 0;
                });
              },
              filterTarget: function(card, player, target) {
                return player != target && get.distance(target, player, 'attack') <= 1 && target.countCards("hej") > 0;
              },
              content: function() {
                "step 0"
                player.discardPlayerCard(target, 'hej', true);
                "step 1"
                if (result.bool) {
                  target.useCard({
                    name: 'sha',
                    isCard: true
                  }, result.cards, player, true, false).viewAs = true;
                }
              },
              group: ["jianni3d8_target"],
              subSkill: {
                target: {
                  trigger: {
                    target: ["shaBefore"],
                  },
                  filter: function(event, player) {
                    if (event.parent.parent.name != 'jianni3d8') return false;
                    return game.hasPlayer(function(current) {
                      return player != current && event.player != current && get.distance(event.player, current, 'attack') <= 1;
                    });
                  },
                  frequent: true,
                  content: function() {
                    'step 0'
                    player.chooseTarget("间逆：选择一名其他角色成为此【杀】的目标", function(card, player, target) {
                      return player != target && trigger.player != target && get.distance(trigger.player, target, 'attack') <= 1;
                    }, false).ai = function(target) {
                      return get.effect(target, {
                        name: 'sha'
                      }, trigger.player, player);
                    };
                    'step 1'
                    if (result.bool) {
                      game.log(player, '选择', result.targets[0], '成为额外目标');
                      trigger.targets.push(result.targets[0]);
                    }
                  },
                  sub: true,
                },
              },
              ai: {
                order: 5,
                expose: 0.3,
                result: {
                  target: function(player, target) {
                    if (target.hasJudge('lebu') || target.hasJudge('bingliang')) return 2;
                    if (target.countCards("j") > 0) return 1;
                    var check = game.hasPlayer(function(current) {
                      return target != current && player != current && get.distance(target, current, 'attack') <= 1 && get.effect(current, {
                        name: 'sha'
                      }, target, target) < 0;
                    });
                    if (check) return -2;
                    return -1;
                  },
                  player: function(player, target) {
                    if (player.hp <= 2) return -2;
                    if (player.countCards('h', 'shan') == 0 && !player.getEquip('tengjia') && !player.getEquip('bagua')) return -1;
                    return -0.5;
                  },
                },
                threaten: 1.8,
              },
            },

            yiluan3d8: {
              audio: "jlsg_zhijiao",
              trigger: {
                target: ["useCardToTargeted"],
              },
              filter: function(event, player) {
                return event.player.countCards("h") > 0 && event.card && event.card.name == 'sha';
              },
              check: function(event, player) {
                var att = get.attitude(player, event.player);
                if (att >= 0) {
                  return event.player.countCards("h") >= 3;
                }
                return true;
              },
              content: function() {
                'step 0'
                player.chooseCardButton('易乱：弃置' + get.translation(trigger.player) + '的一张手牌', trigger.player.getCards('h'), true).set('filterButton', function(button) {
                  return true;
                }).set('ai', function(button) {
                  var att = get.attitude(player, trigger.player);
                  var card = button.link;
                  if (att >= 0) {
                    if (card.name == 'du') return 0.1;
                    return 10 - get.value(card);
                  }
                  if (card.name == 'du') return 8;
                  return get.value(card);
                });
                'step 1'
                if (result.bool) {
                  player.line(trigger.target, 'red');
                  trigger.player.discard(result.links[0], player);
                  trigger.player.draw();
                }
              },
              ai: {
                expose: 0.1,
                threaten: 0.8,
                effect: {
                  target: function(card, player, target, current) {
                    if (card.name != 'sha') return;
                    var cards = player.getCards("h");
                    for (var i = 0; i < cards.length; i++) {
                      if (get.value(cards[i]) >= 8) return [1, 0, 1, -1];
                    }
                    return;
                  },
                },
              },
            },



            tianzuo3d8: {
              audio: "huimin",
              trigger: {
                player: "phaseDiscardBegin",
              },
              init: function(player) {
                player.storage.tianzuo3d8 = 0;
              },
              filter: function(event, player) {
                return true;
              },
              check: function(event, player) {
                var limit = player.getHandcardLimit();
                var count = player.countCards("h");
                if (limit - count >= 0) return true;
                var discard = count - limit + 1;
                var recover1 = 0;
                var recover2 = 0;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i].isOut()) continue;
                  if (players[i] == player.storage.dixi3d8_player) continue;
                  if (players[i].hp < players[i].maxHp) {
                    if (get.attitude(player, players[i]) > 0) {
                      if (players[i].hp < 2) {
                        if (players[i].hp < discard) recover1 += 0.5;
                        if (players[i].hp < discard + 1) recover2 += 0.5;
                      }
                      if (players[i].hp < discard) recover1 += 1;
                      if (players[i].hp < discard + 1) recover2 += 1;
                    } else if (get.attitude(player, players[i]) < 0) {
                      if (players[i].hp < 2) {
                        if (players[i].hp < discard) recover1 -= 0.5;
                        if (players[i].hp < discard + 1) recover2 -= 0.5;
                      }
                      if (players[i].hp < discard) recover1 -= 1;
                      if (players[i].hp < discard + 1) recover2 -= 1;
                    }
                  }
                }
                return recover1 >= 0 || recover2 >= 0;
              },
              content: function() {
                'step 0'
                event.list = ['摸一张牌', '摸两张牌'];
                player.chooseControl(event.list, true).set('prompt', '天祚：选择摸牌数量').ai = function() {
                  var limit = player.getHandcardLimit();
                  var count = player.countCards("h");
                  if (limit - count >= 1) return '摸两张牌';
                  var discard = count - limit + 1;
                  var recover1 = 0;
                  var recover2 = 0;
                  var players = game.filterPlayer();
                  for (var i = 0; i < players.length; i++) {
                    if (players[i].isOut()) continue;
                    if (players[i] == player.storage.dixi3d8_player) continue;
                    if (players[i].hp < players[i].maxHp) {
                      if (get.attitude(player, players[i]) > 0) {
                        if (players[i].hp < 2) {
                          if (players[i].hp < discard) recover1 += 0.5;
                          if (players[i].hp < discard + 1) recover2 += 0.5;
                        }
                        if (players[i].hp < discard) recover1 += 1;
                        if (players[i].hp < discard + 1) recover2 += 1;
                      } else if (get.attitude(player, players[i]) < 0) {
                        if (players[i].hp < 2) {
                          if (players[i].hp < discard) recover1 -= 0.5;
                          if (players[i].hp < discard + 1) recover2 -= 0.5;
                        }
                        if (players[i].hp < discard) recover1 -= 1;
                        if (players[i].hp < discard + 1) recover2 -= 1;
                      }
                    }
                  }
                  if (recover2 >= recover1) return '摸两张牌';
                  return '摸一张牌';
                };
                'step 1'
                if (result.control == '摸一张牌') {
                  player.storage.tianzuo3d8 = 1;
                  player.draw(1);
                }
                if (result.control == '摸两张牌') {
                  player.storage.tianzuo3d8 = 2;
                  player.draw(2);
                }

              },
              group: ["tianzuo3d8_start", "tianzuo3d8_end"],
              subSkill: {
                start: {
                  trigger: {
                    player: "phaseDiscardBefore",
                  },
                  filter: function(event, player) {
                    return (player.storage.tianzuo3d8 == 1 || player.storage.tianzuo3d8 == 2);
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    player.storage.tianzuo3d8 = 0;
                  },
                  sub: true,
                },
                end: {
                  audio: "huimin",
                  trigger: {
                    player: "phaseDiscardAfter",
                  },
                  filter: function(event, player) {
                    return event.cards && event.cards.length > 0 && (player.storage.tianzuo3d8 == 1 || player.storage.tianzuo3d8 == 2);
                  },
                  forced: true,
                  content: function() {
                    var count = trigger.cards.length;
                    var players = game.filterPlayer();
                    for (var i = 0; i < players.length; i++) {
                      if (players[i].hp < count && players[i] != player.storage.dixi3d8_player) players[i].recover();
                    }
                  },
                  sub: true,
                },

              },
            },

            dixi3d8: {
              audio: "shouxi",
              trigger: {
                player: "phaseDiscardEnd",
              },
              init: function(player) {
                player.storage.dixi3d8_player = "";
                player.storage.dixi3d8 = 0;
              },
              filter: function(event, player) {
                return event.cards && event.cards.length > 0 && player.storage.dixi3d8 == 0;
              },
              check: function(event, player) {
                var discard = event.cards.length;
                var players = game.filterPlayer();
                var flag1 = 0;
                var flag2 = 0;
                for (var j = 0; j < players.length; j++) {
                  var target = players[j];
                  var recover1 = 0;
                  if (get.attitude(player, target) > 0 && target.hasJudge("lebu")) continue;
                  for (var i = 0; i < players.length; i++) {
                    if (players[i].isOut()) continue;
                    if (players[i] == target) continue;
                    if (players[i].hp < players[i].maxHp) {
                      if (get.attitude(player, players[i]) > 0) {
                        if (players[i].hp < 2) {
                          if (players[i].hp < discard) recover1 += 0.5;
                        }
                        if (players[i].hp < discard) recover1 += 1;
                      } else if (get.attitude(player, players[i]) < 0) {
                        if (players[i].hp < 2) {
                          if (players[i].hp < discard) recover1 -= 0.5;
                        }
                        if (players[i].hp < discard) recover1 -= 1;
                      }
                    }
                  }
                  if (recover1 >= 0 && get.attitude(player, target) > 0) flag1 = 1;
                  if (recover1 >= 0 && get.attitude(player, target) <= 0) flag2 = 1;
                }
                if (flag1 == 0 && flag2 == 0) return false;
                var cards = event.cards;
                var count = cards.length;
                var value = 0;
                for (var i = 0; i < cards.length; i++) {
                  value += get.value(cards[i]);
                }
                if (count == 3 && value > 20 && flag1 == 1) return true;
                if (count == 4 && value > 20 && flag1 == 1) return true;
                if (value >= 25 && flag1 == 1) return true;
                if (count == 1 && value <= 5 && flag2 == 1) return true;
                if (value <= 0 && flag2 == 1) return true;
                return false;
              },
              content: function() {
                'step 0'
                player.chooseTarget('抵玺：将弃置的牌交给一名其他角色', function(card, player, target) {
                  return target != player;
                }, true).set('ai', function(target) {
                  var recover1 = 0;
                  var players = game.filterPlayer();
                  var discard = trigger.cards.length;
                  for (var i = 0; i < players.length; i++) {
                    if (players[i].isOut()) continue;
                    if (players[i] == target) continue;
                    if (players[i].hp < players[i].maxHp) {
                      if (get.attitude(player, players[i]) > 0) {
                        if (players[i].hp < 2) {
                          if (players[i].hp < discard) recover1 += 0.5;
                        }
                        if (players[i].hp < discard) recover1 += 1;
                      } else if (get.attitude(player, players[i]) < 0) {
                        if (players[i].hp < 2) {
                          if (players[i].hp < discard) recover1 -= 0.5;
                        }
                        if (players[i].hp < discard) recover1 -= 1;
                      }
                    }
                  }
                  if (recover1 < 0) return -1;
                  if (get.attitude(player, target) > 0 && target.hasJudge("lebu")) return 0.1;
                  var value = 0;
                  for (var i = 0; i < trigger.cards.length; i++) {
                    value += get.value(trigger.cards[i]);
                  }
                  if (value <= 5) return -get.attitude(player, target) + target.maxHp - target.hp;
                  else return get.attitude(player, target) + target.maxHp - target.hp + Math.max(0, 3 - target.countCards("h"));
                });
                'step 1'
                if (result.bool) {
                  result.targets[0].gain(trigger.cards, player, 'give');
                  player.storage.dixi3d8_player = result.targets[0];
                  player.storage.dixi3d8_player.addSkill("dixi3d8_buff");
                  player.storage.dixi3d8 = 1;
                }
              },
              group: ["dixi3d8_death"],
              subSkill: {
                death: {
                  trigger: {
                    global: "die",
                  },
                  filter: function(event, player) {
                    return event.player == player.storage.dixi3d8_player;
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    player.storage.dixi3d8_player = "";
                    player.storage.dixi3d8 = 0;
                  },
                  sub: true,
                },
                buff: {
                  mark: true,
                  marktext: "玺",
                  intro: {
                    content: "已发动“抵玺”，无法成为“天祚”对象",
                  },
                },
              },
            },

            jieye3d8: {
              audio: "qiaobian",
              trigger: {
                player: ["chooseToRespondBegin", "chooseToUseBegin"],
              },
              frequent: true,
              init: function(player) {
                player.storage.jieye3d8 = [];
              },
              filter: function(event, player) {
                if (event.responded) return false;
                if (player.storage.jieye3d8.length > 0) return false;
                if (!event.filterCard({
                    name: 'shan'
                  }, player, event)) return false;
                return player.countCards('h');
              },
              content: function() {
                "step 0"
                player.chooseCard('h', '是否将一张手牌置于你的武将牌上视为打出一张【闪】？').set('ai', function(card) {
                  if (card.name == 'du') return 20;
                  return 10 - get.value(card);
                });
                "step 1"
                if (result.bool) {
                  player.$give(result.cards, player, false);
                  player.storage.jieye3d8 = player.storage.jieye3d8.concat(result.cards);
                  player.lose(result.cards, ui.special, 'toStorage');
                  player.markSkill('jieye3d8');
                  player.syncStorage('jieye3d8');
                  game.log(player, '将', result.cards, '置于武将牌上');
                } else event.finish();
                "step 2"
                trigger.untrigger();
                trigger.responded = true;
                trigger.result = {
                  bool: true,
                  card: {
                    name: 'shan',
                    isCard: true
                  }
                };
              },
              intro: {
                content: "cards",
              },
              group: "jieye3d82",
            },

            "jieye3d82": {
              audio: "qiaobian",
              enable: "chooseToUse",
              filter: function(event, player) {
                if (!player.storage.jieye3d8) return false;
                if (player.storage.jieye3d8.length == 0) return false;
                return event.filterCard({
                  name: 'sha'
                }, player, event);
              },
              chooseButton: {
                dialog: function(event, player) {
                  var list = [];
                  if (event.filterCard({
                      name: 'sha'
                    }, player, event)) {
                    list.push(['基本', '', 'sha']);
                    list.push(['基本', '', 'sha', 'fire']);
                    list.push(['基本', '', 'sha', 'thunder']);
                  }
                  return ui.create.dialog('诘谒', [list, 'vcard'], 'hidden');
                },
                check: function(button) {
                  var player = _status.event.player;
                  var card = {
                    name: button.link[2],
                    nature: button.link[3]
                  };
                  if (card.name == 'sha') {
                    if (card.nature == 'fire') return 2.95;
                    else if (card.nature == 'fire') return 2.92;
                    else return 2.9;
                  }
                  return 0;
                },
                backup: function(links, player) {
                  return {
                    filterCard: function() {
                      return false
                    },
                    viewAs: {
                      name: links[0][2],
                      nature: links[0][3],
                      isCard: true
                    },
                    selectCard: -1,
                    popname: true,
                    log: false,
                    precontent: function() {
                      player.gain(player.storage.jieye3d8, 'gain2', 'log');
                      player.storage.jieye3d8 = [];
                      player.logSkill("jieye3d8");
                      player.syncStorage('jieye3d8');
                      player.unmarkSkill('jieye3d8');
                    },
                  }
                },
                prompt: function(links, player) {
                  return '选择' + get.translation(links[0][3] || '') + get.translation(links[0][2]) + '的目标';
                },
              },
              ai: {
                order: 10,
                respondSha: true,
                result: {
                  player: function(player) {
                    return 1;
                  },
                },
              },
            },

            chashi3d8: {
              audio: "choulve",
              trigger: {
                global: "phaseUseBegin",
              },
              filter: function(event, player) {
                return player.countCards("h") > 0 && player != event.player;
              },
              check: function(event, player) {
                return get.attitude(player, event.player) > 0;
              },
              content: function() {
                'step 0'
                player.chooseCard('h', '选择一张手牌展示')
                  .ai = function(card) {
                    var suit = get.suit(card);
                    if (suit == 'spade') return Math.random() * 0.8;
                    if (suit == 'heart') return Math.random() * 0.5;
                    if (suit == 'diamond') return Math.random() * 0.3;
                    if (suit == 'club') return Math.random() * 1;
                    return 0;
                  };
                'step 1'
                if (result.bool) {
                  player.showCards(result.cards[0]);
                  trigger.player.storage.chashi3d8_suit = get.suit(result.cards[0]);
                  trigger.player.addTempSkill("chashi3d8_draw");
                  trigger.player.addTempSkill("chashi3d8_use");
                }
              },
              subSkill: {
                draw: {
                  trigger: {
                    player: "useCard",
                  },
                  filter: function(event, player) {
                    return player.isPhaseUsing() && get.suit(event.card) == player.storage.chashi3d8_suit;
                  },
                  frequent: true,
                  content: function() {
                    player.draw();
                  },
                  mod: {
                    aiOrder: function(player, card, num) {
                      if (player.isPhaseUsing() && get.suit(card) == player.storage.chashi3d8_suit) return num + 10;
                    },
                  },
                },
                use: {
                  trigger: {
                    player: "useCardEnd",
                  },
                  filter: function(event, player) {
                    return player.isPhaseUsing() && player.storage.chashi3d8_suit != "nosuitempty";
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    player.storage.chashi3d8_suit = "nosuitempty";
                  },
                },
              },
            },

            qice3d8: {
              audio: "polu",
              init: function(player) {
                player.storage.qice3d8 = 0;
                player.storage.qice3d8_trick = 0;
              },
              trigger: {
                player: "phaseZhunbeiBegin",
              },
              filter: function(event, player) {
                return true;
              },
              check: function(event, player) {
                if (player.hasJudge('lebu')) {
                  if (player.countCards("h", {
                      name: "wuxie"
                    }) > 0) return true;
                  return false;
                }
                var cards = player.getCards("h");
                for (var i = 0; i < cards.length; i++) {
                  var card = cards[i];
                  if (get.type(card) == 'trick' || get.type(card) == 'delay') {
                    var flag = 0;
                    var players = game.filterPlayer();
                    for (var i = 0; i < players.length; i++) {
                      if (player.canUse(card, players[i])) flag = 1;
                    }
                    if (player.getUseValue(card) >= 0 && flag == 1) return true;
                  }
                }
                if (player.hp <= 1 && player.countCards("h") <= 1) return true;
                if (player.hp <= 2 && player.countCards("h") <= 2) return Math.random() > 0.5;
                return false;
              },
              content: function() {
                player.storage.qice3d8 = 1;
                player.draw(2);
              },
              group: ["qice3d8_start", "qice3d8_jieshu", "qice3d8_trick", "qice3d8_lose"],
              subSkill: {
                start: {
                  trigger: {
                    player: "phaseBegin",
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    player.storage.qice3d8 = 0;
                    player.storage.qice3d8_trick = 0;
                  },
                  sub: true,
                },
                jieshu: {
                  audio: "polu",
                  trigger: {
                    player: "phaseJieshuBegin",
                  },
                  filter: function(event, player) {
                    return player.storage.qice3d8 == 0;
                  },
                  check: function(event, player) {
                    if (player.storage.qice3d8_trick == 1) return true;
                    if (player.hp <= 1 && player.countCards("h") == 0) {
                      if (!player.getEquip(2)) return true;
                      return Math.random() > 0.5;
                    }
                    if (player.hp <= 1 && player.countCards("h") == 1) {
                      return Math.random() > 0.5;
                    }
                    return false;
                  },
                  content: function() {
                    player.storage.qice3d8 = 2;
                    player.draw(2);
                  },
                  sub: true,
                },
                trick: {
                  trigger: {
                    player: "useCardEnd",
                  },
                  filter: function(event, player) {
                    if (get.type(event.card) == 'trick' || get.type(event.card) == 'delay') return true;
                    return false;
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    player.storage.qice3d8_trick = 1;
                  },
                  sub: true,
                },
                lose: {
                  trigger: {
                    player: "phaseEnd",
                  },
                  filter: function(event, player) {
                    return player.storage.qice3d8 == 1 || player.storage.qice3d8 == 2;
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    if (player.storage.qice3d8_trick == 1) {
                      player.storage.qice3d8_trick = 0;
                      player.storage.qice3d8 = 0;
                    } else player.removeSkill("qice3d8");
                  },
                  sub: true,
                },
              },
              ai: {
                expose: 0.2,
                threaten: 1.3,
                effect: {
                  player: function(card, player, target, current) {
                    if (player != _status.currentPhase) return;
                    if (player.storage.qice3d8_trick == 1) {
                      if (get.type(card) == 'trick' || get.type(card) == 'delay') {
                        if (player.countCards("h") <= player.getHandcardLimit() && player.countCards("h", {
                            type: "trick"
                          }) + player.countCards("h", {
                            type: "delay"
                          }) == 1) {
                          return [1, -2];
                        }
                      }
                    }
                    if (player.storage.qice3d8 == 0) return;
                    if (get.type(card) != 'trick' && get.type(card) != 'delay') return;
                    return [1, 5];
                  },
                },
              },
            },

            youzhen3d8: {
              audio: "jlsg_duanlan",
              enable: "phaseUse",
              usable: 1,
              filterTarget: function(card, player, target) {
                return player != target && target.countCards('he');
              },
              selectTarget: 1,
              content: function() {
                "step 0"
                target.chooseToDiscard([1, Infinity], '请弃置至少一张牌', 'he', true).set('ai', function(card) {
                  var player = _status.event.player;
                  if (player.getEquip('tengjia') || player.getEquip('bagua')) return 1 - get.value(card);
                  if (ui.selected.cards.length >= player.countCards("he")) return -1;
                  if (ui.selected.cards.length >= player.countCards("he") - 1) return 4 - get.value(card);
                  if (ui.selected.cards.length >= player.countCards("he") - 2) return 5 - get.value(card);
                  return 6 - get.value(card);
                });
                "step 1"
                if (result.bool) {
                  event.num1 = result.cards.length;
                  player.chooseToDiscard([1, Infinity], '请弃置至少一张牌，或取消不弃置', 'he').set('ai', function(card) {
                    var player = _status.event.player;
                    if (player.getEquip('tengjia') || player.getEquip('bagua')) return -1;
                    if (player.countCards('h', 'shan') && _status.event.getParent().num1 >= 2) return -1;
                    if (ui.selected.cards.length > _status.event.getParent().num1) return -1;
                    if (ui.selected.cards.length == _status.event.getParent().num1) return 5 - get.value(card);
                    return 6 - get.value(card);
                  });
                }
                "step 2"
                if (result.bool) {
                  event.num2 = result.cards.length;
                } else event.num2 = 0;
                "step 3"
                if (event.num1 < event.num2) {
                  player.useCard({
                    name: 'sha',
                    isCard: true
                  }, target, false);
                } else if (event.num1 > event.num2) {
                  target.useCard({
                    name: 'sha',
                    isCard: true
                  }, player, false);
                }
              },
              ai: {
                order: function(name, player) {
                  var cards = player.getCards('he');
                  return cards.length;
                },
                result: {
                  target: function(player, target) {
                    var player = _status.event.player;
                    var num = target.countCards('he');
                    var num1 = player.countCards('he');
                    var count = 0;
                    if (player.getEquip('tengjia') || player.getEquip('bagua')) count -= 2;
                    if (num1 > player.hp) count -= 1;
                    if (num1 > 2) count -= 0.8;
                    if (num1 <= 1 && !player.getEquip('tengjia')) count += (2 - num1);
                    count += 0.7;
                    if (num < player.countCards('he')) count -= 1;
                    if (num == player.countCards('he')) {
                      if (Math.random() > 0.5) count -= 0.8;
                      else count -= 0.6;
                    }
                    return Math.min(0, count);
                  },
                },
                threaten: 1.3,
              },
            },

            zhilian3d8: {
              audio: "xinfu_wuniang",
              trigger: {
                global: "phaseJieshuBegin",
              },
              filter: function(event, player) {
                var count = 2;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i].getHistory('useCard').length > 0) count -= 1;
                }
                return count == 0;
              },
              frequent: true,
              content: function() {
                'step 0'
                event.player1 = null;
                event.player2 = null;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i].getHistory('useCard').length > 0) {
                    if (event.player1 == null) event.player1 = players[i];
                    else event.player2 = players[i];
                  }
                }
                'step 1'
                player.chooseControl('各摸一张牌', '各弃一张牌', function(event, player) {
                  var att1 = get.attitude(player, event.player1);
                  var att2 = get.attitude(player, event.player2);
                  if (att1 <= 0 && att2 <= 0) return '各弃一张牌';
                  if (att1 >= 0 && att2 >= 0) return '各摸一张牌';
                  if (event.player1 == player || event.player2 == player) {
                    var cards = [];
                    game.countPlayer2(function(current) {
                      current.getHistory('lose', function(evt) {
                        if (evt.position == ui.discardPile) {
                          for (var i = 0; i < evt.cards.length; i++) {
                            if (evt.cards[i].name == 'sha') cards.add(evt.cards[i]);
                          }
                        }
                      })
                    });
                    game.getGlobalHistory('cardMove', function(evt) {
                      if (evt.name == 'cardsDiscard') {
                        for (var i = 0; i < evt.cards.length; i++) {
                          if (evt.cards[i].name == 'sha') cards.add(evt.cards[i]);
                        }
                      }
                    });
                    if (player.hp <= 1 || player.countCards("h") <= 2) return '各摸一张牌';
                    if (player.countCards('h', {
                        type: 'sha'
                      }) > 0) return '各弃一张牌';
                    if (Math.random() > 0.5) return '各摸一张牌';
                    return '各弃一张牌';
                  }
                  var player3 = null;
                  if (att1 >= 0) player3 = event.player1;
                  else player3 = event.player2;
                  if (player3.hp <= 1 || player3.countCards("h") <= 2) return '各摸一张牌';
                  if (Math.random() > 0.5) return '各摸一张牌';
                  return '各弃一张牌';
                }).set('prompt', '枝连：令' + get.translation(event.player1) + '与' + get.translation(event.player2) + '各摸或各弃一张牌');
                'step 2'
                if (result.control) {
                  if (result.control == '各摸一张牌') {
                    event.player1.draw();
                    event.player2.draw();
                    event.goto(4);
                  } else {
                    event.player1.chooseToDiscard("枝连：弃置一张牌", 1, 'he', true).ai = function(card) {
                      if (card.name == 'du' && player.hp == 1) return 1;
                      if (event.player1 == player && card.name == 'sha') return 30;
                      if (event.player2 == player && card.name == 'sha') return 13;
                      return 20 - get.value(card);
                    };
                    event.goto(3);
                  }
                }
                'step 3'
                event.player2.chooseToDiscard("枝连：弃置一张牌", 1, 'he', true).ai = function(card) {
                  if (card.name == 'du' && player.hp == 1) return 1;
                  if (event.player2 == player && card.name == 'sha') return 30;
                  if (event.player1 == player && card.name == 'sha') return 13;
                  return 20 - get.value(card);
                };
                'step 4'
                var cards = [];
                game.countPlayer2(function(current) {
                  current.getHistory('lose', function(evt) {
                    if (evt.position == ui.discardPile) {
                      for (var i = 0; i < evt.cards.length; i++) {
                        if (evt.cards[i].name == 'sha') cards.add(evt.cards[i]);
                      }
                    }
                  })
                });
                game.getGlobalHistory('cardMove', function(evt) {
                  if (evt.name == 'cardsDiscard') {
                    for (var i = 0; i < evt.cards.length; i++) {
                      if (evt.cards[i].name == 'sha') cards.add(evt.cards[i]);
                    }
                  }
                });
                if (cards.length > 0 && (event.player1 == player || event.player2 == player)) player.gain(cards, 'gain2');
              },
            },

            jijian3d8: {
              audio: "xinfu_xushen",
              enable: "phaseUse",
              usable: 1,
              filterTarget: function(card, player, target) {
                return player != target && target.countCards('h') && target.sex == 'male';
              },
              content: function() {
                "step 0"
                player.choosePlayerCard(target, 'h', 1, true);
                "step 1"
                event.cd = result.links[0];
                player.showCards('赍剑', event.cd);
                "step 2"
                if (!game.hasPlayer(function(current) {
                    return target.canUse(event.cd, current);
                  }) || get.type(event.cd) == 'delay' || get.type(event.cd) == 'equip') event.finish();
                else {
                  player.chooseCard({
                    filterCard: function(card) {
                      return get.type(card) == 'equip' || card.name == 'sha';
                    },
                    position: 'he',
                    selectCard: 1,
                    ai: function(card) {
                      if (!game.hasPlayer(function(current) {
                          return target.canUse(event.cd, current) && get.effect(current, event.cd, target, player) > 0;
                        })) return -1;
                      return 10 - get.value(card);
                    },
                    prompt: '交给' + get.translation(target) + '一张装备牌或【杀】，视为其使用' + get.translation(event.cd)
                  });
                }
                "step 3"
                if (result.bool) {
                  player.give(result.cards[0], target, 'visible');
                  var card = game.createCard(event.cd.name, event.cd.suit, event.cd.number, event.cd.nature);
                  target.chooseUseTarget(card, true, false);
                }
              },
              ai: {
                order: 9,
                result: {
                  target: function(player, target) {
                    var cards = player.getCards("he");
                    var flag = 0;
                    for (var i = 0; i < cards.length; i++) {
                      if (cards[i].name == 'sha' || get.type(cards[i]) == 'equip') flag = 1;
                    }
                    if (flag == 0) return 0;
                    return 1;
                  },
                },
              },
            },

            huikuo3d8: {
              audio: "xiashu",
              enable: ["chooseToUse"],
              filter: function(event, player) {
                var cards = player.getCards('h');
                if (!cards || cards.length == 0) return false;
                return true;
              },
              check: function(card) {
                var event = _status.event;
                var val = 7;
                if (event.parent.parent.parent.parent.card) {
                  val = get.value(event.parent.parent.parent.parent.card);
                }
                var count = get.player().countCards("h");
                var hands = count;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  count = Math.min(count, players[i].countCards("h"));
                }
                var count = Math.max(hands - count, 1);
                console.log(val);
                if (count == 1) return val - get.value(card)
                if (count == 2) return val - 2 - get.value(card);
                if (count == 3) return val - 4 - get.value(card);
                return -1;
              },
              selectCard: function() {
                var count = get.player().countCards("h");
                var hands = count;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  count = Math.min(count, players[i].countCards("h"));
                }
                return Math.max(hands - count, 1);
              },
              viewAsFilter: function(player) {
                if ((!player.countCards('h')) || player.countCards('h') == 0) return false;
                return true;
              },
              filterCard: true,
              position: "h",
              viewAs: "wuxie",
              prompt: "是否将手牌当【无懈可击】使用，至你手牌为场上最少？",
              ai: {
                basic: {
                  useful: [6, 4, 3],
                  value: [6, 4, 3],
                },
                result: {
                  player: 1,
                },
                expose: 0.2,
              },
            },

            linrun3d8: {
              audio: "kuanshi",
              trigger: {
                global: ["chooseToRespondBefore", "chooseToUseBefore"],
              },
              filter: function(event, player) {
                if (event.player == player) return false;
                if (event.responded) return false;
                if (!event.filterCard({
                    name: 'shan'
                  }, player, event)) return false;
                var hp = player.hp;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  hp = Math.min(players[i].hp, hp);
                }
                if (event.player.hp != hp) return false;
                return true;
              },
              check: function(event, player) {
                return get.attitude(player, event.player) > 0;
              },
              content: function() {
                "step 0"
                var next = player.chooseToRespond('是否替' + get.translation(trigger.player) + '打出一张闪？', {
                  name: 'shan'
                });
                next.set('ai', function() {
                  if (trigger.parent && trigger.parent.player && get.damageEffect(trigger.player, trigger.parent.player, player) >= 0) return false;
                  return true;
                });
                next.autochoose = lib.filter.autoRespondShan;
                "step 1"
                if (result.bool) {
                  event.finish();
                  trigger.result = {
                    bool: true,
                    card: {
                      name: 'shan'
                    }
                  };
                  trigger.responded = true;
                } else trigger.player.draw();
              },
              group: ["linrun3d8_init"],
            },

            linrun3d8_init: {
              audio: "kuanshi",
              trigger: {
                global: ["chooseToRespondBefore", "chooseToUseBefore"],
              },
              frequent: true,
              filter: function(event, player) {
                if (event.parent.parent.skill && event.parent.parent.skill == 'linrun3d8') return false;
                if (event.player != player) return false;
                if (event.responded) return false;
                if (!event.filterCard({
                    name: 'shan'
                  }, player, event)) return false;
                var hp = player.hp;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  hp = Math.min(players[i].hp, hp);
                }
                if (event.player.hp != hp) return false;
                return true;
              },
              content: function() {
                player.draw();
              },
            },

            renxian3d8: {
              audio: "jlsg_diezhang",
              trigger: {
                player: "phaseUseAfter",
              },
              filter: function(event, player) {
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i].countCards("he") > 0) return true;
                }
                return false;
              },
              check: function(event, player) {
                var next = player.next;
                var att = get.attitude(player, next);
                var judges = next.getCards('j');
                var cards = player.getCards("h");
                var club = 0;
                var heart = 0;
                var shandian = 0;
                var small_cards = 0;
                var tiny_cards = 0;
                var can_sha = 0;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i] == player) continue;
                  if (player.canUse({
                      name: 'sha'
                    }, players[i], false) && get.effect(players[i], {
                      name: 'sha'
                    }, player) > 0) can_sha = 1;
                }
                for (var i = 0; i < cards.length; i++) {
                  var card = cards[i];
                  if (get.value(card) <= 4) tiny_cards += 1;
                  if (get.value(card) <= 6) small_cards += 1;
                  if (get.value(card) >= 8) continue;
                  if (get.suit(card) == 'heart') heart = 1;
                  if (get.suit(card) == 'club') club = 1;
                  if (get.suit(card) == 'spade' && card.number >= 2 && card.number <= 9) shandian = 1;
                }
                if (att > 0 && !player.hasWuxie() && judges.length > 0) {
                  if (judges[0].name == 'lebu' && heart == 1) return true;
                  if (judges[0].name == 'bingliang' && club == 1) return true;
                }
                if (att < 0 && judges.length > 0) {
                  if (judges[0].name == 'shandian' && shandian == 1) return true;
                }
                if (small_cards >= 2 && player.isDamaged()) return true;
                if (tiny_cards >= 2 && att < 0 && can_sha == 1) return true;
                for (var i = 0; i < players.length; i++) {
                  if (players[i] == player) continue;
                  var att = get.attitude(player, players[i]);
                  if (att == 0) continue;
                  var cards = players[i].getCards("he");
                  if (att > 0) {
                    if (cards.length - players[i].hp >= 2) return true;
                  }
                  if (cards.length == 1) return true;
                  var can_sha = 0;
                  for (var j = 0; j < players.length; j++) {
                    if (players[i] == players[j]) continue;
                    if (players[i].canUse({
                        name: 'sha'
                      }, players[j], false) && get.effect(players[j], {
                        name: 'sha'
                      }, players[i]) > 0) can_sha = 1;
                  }
                  if (can_sha == 0 && !players[i].isDamaged()) return true;
                }
                return false;
              },
              content: function() {
                'step 0'
                player.chooseTarget('任险：令一名角色将一至两张牌置于牌堆顶', true, function(card, player, target) {
                  return true;
                }).ai = function(target) {
                  if (target == player) {
                    var next = player.next;
                    var att = get.attitude(player, next);
                    var judges = next.getCards('j');
                    var cards = player.getCards("h");
                    var club = 0;
                    var heart = 0;
                    var shandian = 0;
                    var small_cards = 0;
                    var tiny_cards = 0;
                    var can_sha = 0;
                    var players = game.filterPlayer();
                    for (var i = 0; i < players.length; i++) {
                      if (players[i] == player) continue;
                      if (player.canUse({
                          name: 'sha'
                        }, players[i], false) && get.effect(players[i], {
                          name: 'sha'
                        }, player) > 0) can_sha = 1;
                    }
                    for (var i = 0; i < cards.length; i++) {
                      var card = cards[i];
                      if (get.value(card) <= 4) tiny_cards += 1;
                      if (get.value(card) <= 6) small_cards += 1;
                      if (get.value(card) >= 8) continue;
                      if (get.suit(card) == 'heart') heart = 1;
                      if (get.suit(card) == 'club') club = 1;
                      if (get.suit(card) == 'spade' && card.number >= 2 && card.number <= 9) shandian = 1;
                    }
                    if (att > 0 && !player.hasWuxie() && judges.length > 0) {
                      if (judges[0].name == 'lebu' && heart == 1) return Math.max(next.countCards("h") + 1 - next.getHandcardLimit(), 0.1);
                      if (judges[0].name == 'bingliang' && club == 1) return 0.5;
                    }
                    if (att < 0 && judges.length > 0) {
                      if (judges[0].name == 'shandian' && shandian == 1) return 2;
                    }
                    if (small_cards >= 2 && player.isDamaged()) return player.maxHp - player.hp;
                    if (tiny_cards >= 2 && att < 0 && can_sha == 1) return 1.5;
                    return 0;
                  }

                  var att = get.attitude(player, target);
                  if (att == 0) return 0;
                  var cards = target.getCards("he");
                  var players = game.filterPlayer();
                  if (att > 0) {
                    if (cards.length - target.hp >= 2) return target.maxHp - target.hp;
                    return -1;
                  }
                  if (cards.length == 1) return 2.1;
                  var can_sha = 0;
                  for (var j = 0; j < players.length; j++) {
                    if (target == players[j]) continue;
                    if (target.canUse({
                        name: 'sha'
                      }, players[j], false) && get.effect(players[j], {
                        name: 'sha'
                      }, target) > 0) can_sha = 1;
                  }
                  if (can_sha == 0 && !target.isDamaged()) return 2;
                  return -1;
                }
                'step 1'
                if (result.bool) {
                  event.target = result.targets[0];
                  player.line(event.target, "blue");
                  game.log(player, "选择了", event.target);
                  result.targets[0].chooseCard('he', '将一张牌置于牌堆顶', 1, true).set('ai', function(card) {
                    var next = player.next;
                    var judges = next.getCards('j');
                    var att = get.attitude(event.target, next);
                    var players = game.filterPlayer();
                    if (judges.length > 0) {
                      var judge = get.judge(judges[0]);
                      if (get.value(card) < 8 && att > 0) return judge(card);
                      if (get.value(card) < 8 && att < 0) return -judge(card);
                    }
                    if (att > 0 && next.hp < event.target.hp && next.countCards("h") < event.target.countCards("h") && judges.length == 0) {
                      return get.value(card);
                    }
                    return 20 - get.value(card);
                  }).set('complexCard', true);
                } else event.finish();
                'step 2'
                if (result.bool) {
                  event.cards = [];
                  event.cards.add(result.cards[0]);
                  event.count = 1;
                  event.target.chooseCard('he', '将另一张牌置于牌堆顶', 1, false).set('ai', function(card) {
                    var next = player.next;
                    var judges = next.getCards('j');
                    var att = get.attitude(event.target, next);
                    var players = game.filterPlayer();
                    if (judges.length > 1) {
                      var judge = get.judge(judges[1]);
                      if (get.value(card) < 8 && att > 0) return judge(card);
                      if (get.value(card) < 8 && att < 0) return -judge(card);
                    }
                    if (att > 0 && next.hp < event.target.hp && next.countCards("h") < event.target.countCards("h") && judges.length < 1) {
                      return get.value(card);
                    }
                    var can_sha = 0;
                    for (var j = 0; j < players.length; j++) {
                      if (event.target == players[j]) continue;
                      if (event.target.canUse('sha', players[j]) && get.effect(players[j], {
                          name: 'sha'
                        }, event.target) > 0) can_sha = 1;
                    }
                    if (can_sha == 0 && !event.target.isDamaged()) return -get.value(card);
                    return 6.1 - get.value(card);
                  }).set('complexCard', true).set('filterCard', function(card) {
                    return card != result.cards[0];
                  });
                }
                'step 3'
                if (result.cards) {
                  event.cards.add(result.cards[0]);
                  event.count += 1;
                }
                'step 4'
                if (event.count == 1) {
                  game.log(event.target, "将一张牌置于牌堆顶");
                } else game.log(event.target, "将两张牌置于牌堆顶");
                for (var i = event.cards.length - 1; i >= 0; i--) {
                  ui.cardPile.insertBefore(event.cards[i], ui.cardPile.firstChild);
                }
                game.broadcastAll(function(player) {
                  var cards = [];
                  var cardx = ui.create.card();
                  var cardx2 = ui.create.card();
                  cards.add(cardx);
                  if (event.count == 2) cards.add(cardx2);
                  cardx.classList.add('infohidden');
                  cardx.classList.add('infoflip');
                  cardx2.classList.add('infohidden');
                  cardx2.classList.add('infoflip');
                  event.target.$throw(cards, 1000, 'nobroadcast');
                }, event.target);
                ui.updatehl();
                event.target.update();
                ui.clear();
                if (event.count == 1) event.finish();
                'step 5'
                event.target.chooseControl('使用一张【杀】', '回复1点体力', function(event, player) {
                  var can_sha = 0;
                  var can_da_sha = 0;
                  var players = game.filterPlayer();
                  for (var j = 0; j < players.length; j++) {
                    if (event.target == players[j]) continue;
                    if (event.target.canUse({
                        name: 'sha'
                      }, players[j], false) && get.effect(players[j], {
                        name: 'sha'
                      }, event.target) > 0) can_sha = 1;
                    if (event.target.canUse({
                        name: 'sha'
                      }, players[j], false) &&
                      get.effect(players[j], {
                        name: 'sha'
                      }, event.target) > get.recoverEffect(event.target, event.target, event.target)) can_da_sha = 1;
                  }
                  if (!event.target.isDamaged()) {
                    if (can_sha == 1) return '使用一张【杀】';
                    return '回复1点体力';
                  }
                  if (can_da_sha == 1 && event.target.hp >= 2) return '使用一张【杀】';
                  return '回复1点体力';
                }).set('prompt', '任险：选择一项执行');
                'step 6'
                if (result.control) {
                  if (result.control == '回复1点体力') event.target.recover();
                  else {
                    event.target.chooseTarget("任险：选择一名角色成为【杀】的目标", function(card, player, target) {
                      return event.target.canUse({
                        name: 'sha'
                      }, target, false);
                    }, true).ai = function(target) {
                      return get.effect(target, {
                        name: 'sha'
                      }, event.target);
                    }
                  }
                }
                'step 7'
                if (result.bool) {
                  event.target.useCard({
                    name: 'sha'
                  }, result.targets[0], true);
                }
              },
              ai: {
                expose: 0.7,
                threaten: 1.5,
              },
            },

            chouti3d8: {
              audio: "spwenji",
              enable: "phaseUse",
              derivation: "kunxie3d8",
              init: function(player) {
                player.storage.chouti3d8_player = null;
              },
              filter: function(event, player) {
                if (player.countCards("he") == 0) return false;
                if (player.storage.chouti3d8_player != null) return false;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (!players[i].hasSkill("kunxie3d8") && players[i] != player) return true;
                }
                return false;
              },
              content: function() {
                "step 0"
                var num1 = player.countCards('he');
                player.chooseCardTarget({
                  filterCard: function(card) {
                    return true;
                  },
                  position: 'he',
                  selectCard: 1,
                  selectTarget: 1,
                  filterTarget: function(card, player, target) {
                    return player != target && !target.hasSkill("kunxie3d8");
                  },
                  ai1: function(card) {
                    if (get.type(card) == "trick" || get.type(card) == "delay") {
                      return -1;
                    }
                    return 6 - get.value(card);
                  },
                  ai2: function(target) {
                    if (get.attitude(player, target) >= 0) return -1;
                    return -get.attitude(player, target);
                  },
                  prompt: '抽梯：将一张牌交给一名角色，然后令其获得“困挟”'
                });
                "step 1"
                if (result.bool) {
                  player.storage.chouti3d8_player = result.targets[0];
                  player.line(result.targets[0], "red");
                  result.targets[0].gain(result.cards, "gain2");
                  result.targets[0].addSkill("kunxie3d8");
                  result.targets[0].storage.kunxie3d8_player = player;
                }
              },
              ai: {
                order: 1,
                expose: 0.7,
                result: {
                  player: function(player, target) {
                    var cards = player.getCards('he');
                    var flag = 0;
                    for (var i = 0; i < cards.length; i++) {
                      var card = cards[i];
                      if (get.type(card) != "trick" && get.type(card) != "delay") {
                        if (get.value(card) < 6) flag = 1;
                      }
                    }
                    var players = game.filterPlayer();
                    for (var i = 0; i < players.length; i++) {
                      if (!players[i].hasSkill("kunxie3d8") && players[i] != player && flag == 1) flag = 2;
                    }
                    if (flag != 2) return -1;
                    return 1;
                  }
                },
                threaten: 1.8,
              },
            },

            kunxie3d8: {
              forced: true,
              mod: {
                cardEnabled: function(card, player) {
                  if (player.countCards("h") == player.getHandcardLimit()) return false;
                },
                cardUsable: function(card, player) {
                  if (player.countCards("h") == player.getHandcardLimit()) return false;
                },
                cardSavable: function(card, player) {
                  if (player.countCards("h") == player.getHandcardLimit()) return false;
                },
              },
              group: ["kunxie3d8_cancel"],
              subSkill: {
                cancel: {
                  audio: "spwenji",
                  enable: "phaseUse",
                  filter: function(event, player) {
                    if (!player.storage.kunxie3d8_player.isAlive()) return false;
                    var cards = player.getCards('h');
                    var flag = 0;
                    for (var i = 0; i < cards.length; i++) {
                      var card = cards[i];
                      if (get.type(card) == "trick" || get.type(card) == "delay") return true;
                    }
                    return false;
                  },
                  content: function() {
                    "step 0"
                    player.chooseCardTarget({
                      filterCard: function(card) {
                        return get.type(card) == 'trick' || get.type(card) == 'delay';
                      },
                      position: 'he',
                      selectCard: 1,
                      selectTarget: 1,
                      filterTarget: function(card, player, target) {
                        return target == player.storage.kunxie3d8_player;
                      },
                      ai1: function(card) {
                        return 9 - get.value(card);
                      },
                      ai2: function(target) {
                        return 1;
                      },
                      prompt: '将一张锦囊牌交给令你获得“困挟”的角色，然后失去“困挟”'
                    });
                    "step 1"
                    if (result.bool) {
                      player.storage.kunxie3d8_player = null;
                      player.line(result.targets[0], "red");
                      result.targets[0].gain(result.cards, "gain2");
                      player.removeSkill("kunxie3d8");
                      result.targets[0].storage.chouti3d8_player = null;
                    }
                  },
                  ai: {
                    order: 8,
                    expose: 0.7,
                    result: {
                      player: function(player, target) {
                        var cards = player.getCards('h');
                        var flag = 0;
                        for (var i = 0; i < cards.length; i++) {
                          var card = cards[i];
                          if (get.type(card) == "trick" || get.type(card) == "delay") {
                            if (get.value(card) < 9) flag = 1;
                          }
                        }
                        if (flag != 1) return -1;
                        return 1;
                      }
                    },
                    threaten: 1.8,
                  },
                },
              },
            },

            zonghuo3d8: {
              audio: "sptunjiang",
              trigger: {
                player: "loseAfter",
              },
              frequent: true,
              filter: function(event, player) {
                var evt = event.getl(player);
                return evt && evt.player == player && evt.hs && evt.hs.length > 0;
              },
              content: function() {
                "step 0"
                event.count = trigger.getl(player).hs.length;
                event.result_count = 0;
                "step 1"
                event.count--;
                player.chooseControl('+1', '-1', '不变', function(event, player) {
                  var current = _status.currentPhase;
                  var att = get.attitude(player, current);
                  if (att >= 0) return "+1";
                  if (att < 0 && !current.hasSkill("kunxie3d8")) return "-1";
                  if (current.countCards('h') == current.getHandcardLimit()) return '不变';
                  if (current.countCards('h') == current.getHandcardLimit() + 1) return '+1';
                  return "-1";
                }).set('prompt', '宗祸：令' + get.translation(_status.currentPhase) + '当前回合手牌上限+1或-1');
                "step 2"
                if (result.control) {
                  if (result.control == '+1') {
                    player.line(_status.currentPhase, "red");
                    game.log(player, "令", _status.currentPhase, "当前回合手牌上限+1");
                    event.result_count += 1;
                  } else {
                    player.line(_status.currentPhase, "red");
                    game.log(player, "令", _status.currentPhase, "当前回合手牌上限-1");
                    event.result_count -= 1;
                  }
                }
                if (event.count > 0) {
                  event.goto(1);
                } else {
                  _status.currentPhase.storage.zonghuo3d8_buff = event.result_count;
                  _status.currentPhase.addTempSkill("zonghuo3d8_buff", "phaseAfter");
                }
              },
              ai: {
                expose: 0.5,
                threaten: 2.0,
              },
            },

            zonghuo3d8_buff: {
              mod: {
                maxHandcard: function(player, num) {
                  return num + player.storage.zonghuo3d8_buff;
                },
              },
              forced: true,
              popup: false,
              silent: true,
            },

            baiyou3d8: {
              audio: "drlt_congjian",
              trigger: {
                player: "phaseJieshuBegin",
              },
              filter: function(event, player) {
                return true;
              },
              check: function(event, player) {
                var cards = player.getCards("h");
                var players = game.filterPlayer();
                for (var i = 0; i < cards.length; i++) {
                  if (cards[i].name == 'sha') return false;
                }
                var count = 0;
                for (var i = 0; i < players.length; i++) {
                  if (players[i] == player) continue;
                  if (get.attitude(player, players[i]) >= 0) continue;
                  if (get.distance(player, players[i], 'attack') > 1 && get.effect(player, {
                      name: 'sha'
                    }, players[i], player) < 0) count += 1;
                }
                return count <= 2;
              },
              content: function() {
                "step 0"
                player.showHandcards();
                if (player.countCards("h", {
                    name: "sha"
                  }) > 0) {
                  event.finish();
                }
                "step 1"
                player.chooseControl(["摸牌", "回复体力"], true).set('prompt', '败诱：摸两张牌或回复1点体力').ai = function() {
                  if (player.hp <= 2) return "回复体力";
                  if (player.isDamaged()) {
                    if (player.getCards("h") <= 2) return "摸牌";
                    return "回复体力";
                  }
                  return "摸牌";
                };
                "step 2"
                if (result.control) {
                  if (result.control == "摸牌") player.draw(2);
                  else player.recover();
                  player.addTempSkill('baiyou3d8_debuff', {
                    player: 'phaseBegin'
                  });
                }
              },
              ai: {
                expose: 0.2,
                threaten: 1.5,
              },
              mod: {
                aiUseful: function(player, card, num) {
                  var cards = player.getCards("h");
                  var players = game.filterPlayer();
                  var count = 0;
                  for (var i = 0; i < players.length; i++) {
                    if (players[i] == player) continue;
                    if (get.attitude(player, players[i]) >= 0) continue;
                    if (get.distance(player, players[i], 'attack') > 1 && get.effect(player, {
                        name: 'sha'
                      }, players[i], player) < 0) count += 1;
                  }
                  if (count <= 2 && card.name == 'sha') return 0;
                },
              },
            },

            baiyou3d8_debuff: {
              global: "baiyou3d8_debuff1",
              forced: true,
            },

            baiyou3d8_debuff1: {
              mod: {
                targetInRange: function(card, player, target) {
                  if (target.hasSkill('baiyou3d8_debuff')) {
                    return true;
                  }
                },
              },
            },

            fandi3d8: {
              audio: "drlt_xiongluan",
              unique: true,
              enable: "phaseUse",
              skillAnimation: true,
              animationColor: "gray",
              limited: true,
              init: function(player) {
                player.storage.fandi3d8 = false;
              },
              filter: function(event, player) {
                if (player.storage.fandi3d8) return false;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i] != player && players[i].countCards("h") > 0) return true;
                }
                return false;
              },
              content: function() {
                "step 0"
                player.awakenSkill('fandi3d8');
                player.storage.fandi3d8 = true;
                event.current = player.next;
                "step 1"
                if (event.current != player && event.current.countCards("h") > 0) {
                  event.current.chooseCard('h', true).set('ai', function(card) {
                    return 1;
                  });
                } else if (event.current == player) event.goto(3);
                else {
                  event.current = event.current.next;
                  event.goto(1);
                }
                "step 2"
                if (result.cards) {
                  var card = result.cards[0];
                  event.current.storage.fandi3d8_card = card;
                  event.current = event.current.next;
                }
                event.goto(1);
                "step 3"
                event.current = player.next;
                while (event.current != player) {
                  if (event.current.countCards("h") > 0) {
                    event.current.showCards(event.current.storage.fandi3d8_card);
                  }
                  event.current = event.current.next;
                }
                player.chooseControl(["红色", "黑色"], true).set('prompt', '反镝：选择一种颜色').ai = function() {
                  var players = game.filterPlayer();
                  for (var i = 0; i < players.length; i++) {
                    if (players[i] == player) continue;
                    if (players[i].countCards("h") == 0) continue;
                    var att = get.attitude(player, players[i]);
                    var color = get.color(players[i].storage.fandi3d8_card);
                    var red = 0;
                    var black = 0;
                    var red_risk = 0;
                    var black_risk = 0;
                    if (att > 0 && color == "red") {
                      red += 2;
                      if (players[i].countCards('h') <= 1 || players[i].hp <= 1) red_risk += 1;
                    }
                    if (att > 0 && color == "black") {
                      black += 2;
                      if (players[i].countCards('h') <= 1 || players[i].hp <= 1) black_risk += 1;
                    }
                    if (att < 0 && color == "red") {
                      black += Math.min(2, players[i].countCards("he"));
                      if (players[i].countCards('h') <= 1 || players[i].hp <= 1) black_risk += 1;
                    }
                    if (att < 0 && color == "black") {
                      red += Math.min(2, players[i].countCards("he"));
                      if (players[i].countCards('h') <= 1 || players[i].hp <= 1) red_risk += 1;
                    }
                    if (red > black) return "红色";
                    if (black > red) return "黑色";
                    if (red_risk > black_risk) return "红色";
                    if (black_risk > red_risk) return "黑色";
                    if (Math.random() > 0.5) return "红色";
                    else return "黑色";
                  }
                };
                "step 4"
                if (result.control) {
                  var color = 'black';
                  if (result.control == "红色") {
                    game.log(player, "选择了红色");
                    color = 'red';
                  } else game.log(player, "选择了黑色");
                  var players = game.filterPlayer();
                  for (var i = 0; i < players.length; i++) {
                    if (players[i] == player) continue;
                    if (players[i].countCards("h") == 0) continue;
                    var bcolor = get.color(players[i].storage.fandi3d8_card);
                    if (bcolor == color) players[i].draw(2);
                    else players[i].chooseToDiscard("反镝：弃置两张牌", 2, 'he', true);
                  }
                }
              },
              ai: {
                order: 9,
                expose: 0.5,
                threaten: 2,
                result: {
                  player: function(player) {
                    var friend = 0;
                    var risk_friend = 0;
                    var risk_enemy = 0;
                    var enemy = 0;
                    var players = game.filterPlayer();
                    if (players.length == 2) return 1;
                    if (game.roundNumber > players.length) return 1;
                    for (var i = 0; i < players.length; i++) {
                      if (players[i] == player) continue;
                      var att = get.attitude(player, players[i]);
                      if (players[i].countCards('h') == 0) continue;
                      if (att > 0) {
                        friend += 1;
                        if (players[i].countCards("he") <= 1 || players[i].hp <= 1) risk_friend += 1;
                      }
                      if (att < 0) {
                        enemy += 1;
                        if (players[i].countCards("he") <= 1 || players[i].hp <= 1) risk_enemy += 1;
                      }
                    }
                    if (risk_friend + risk_enemy >= players.length / 2) return 1;
                    if (friend > enemy && risk_friend > 0) return 1;
                    if (friend > enemy) {
                      if (Math.random() > 0.5) return 1;
                      return -1;
                    }
                    if (friend == 0 && enemy == 0) return -1;
                    if (Math.random() > 0.75) return 1;
                    return -1;
                  },
                },
              },
            },

            jiefan3d8: {
              audio: "jiefan",
              enable: "chooseToUse",
              hiddenCard: function(player, name) {
                if (player.countDisabled() >= 5) return false;
                var type = get.type(name);
                return type == 'basic';
              },
              filter: function(event, player) {
                if (player.countDisabled() >= 5) return false;
                var type = 'basic';
                for (var name of lib.inpile) {
                  if (get.type(name) != type) continue;
                  if (event.filterCard({
                      name: name,
                      isCard: true
                    }, player, event)) return true;
                }
                return false;
              },
              chooseButton: {
                dialog: function(event, player) {
                  var dialog = ui.create.dialog('解烦', 'hidden');
                  var table = document.createElement('div');
                  table.classList.add('add-setting');
                  table.style.margin = '0';
                  table.style.width = '100%';
                  table.style.position = 'relative';
                  for (var i = 1; i < 6; i++) {
                    if (player.isDisabled(i)) continue;
                    var td = ui.create.div('.shadowed.reduce_radius.pointerdiv.tdnode');
                    td.innerHTML = '<span>' + get.translation('equip' + i) + '</span>';
                    td.link = i;
                    td.addEventListener(lib.config.touchscreen ? 'touchend' : 'click', ui.click.button);
                    for (var j in lib.element.button) {
                      td[j] = lib.element.button[j];
                    }
                    table.appendChild(td);
                    dialog.buttons.add(td);
                  }
                  dialog.content.appendChild(table);
                  var type = 'basic';
                  var list = [];
                  for (var name of lib.inpile) {
                    if (get.type(name) != type) continue;
                    if (event.filterCard({
                        name: name,
                        isCard: true
                      }, player, event)) {
                      list.push([type, '', name]);
                      if (name == 'sha') {
                        list.push([type, '', name, 'fire']);
                        list.push([type, '', name, 'thunder']);
                        list.push([type, '', name, 'ice']);
                      }
                    }
                  }
                  dialog.add([list, 'vcard']);
                  return dialog;
                },
                filter: function(button) {
                  if (ui.selected.buttons.length && typeof button.link == typeof ui.selected.buttons[0].link) return false;
                  return true;
                },
                select: 2,
                check: function(button) {
                  var player = _status.event.player;
                  var name = button.link[2];
                  var evt = _status.event.getParent();
                  if (typeof button.link == 'number') {
                    var card = player.getEquip(button.link);
                    var flag = 0;
                    if (card) {
                      var val = get.value(card);
                      //if(val>0) return 0;
                      //return 5-val;
                      flag = 0.5;
                    }
                    if (button.link == 1) return 3.2;
                    if (button.link == 2) {
                      if (evt.type == 'dying') return 1;
                      return 0;
                    }
                    if (button.link == 3) return 4.5 + flag;
                    if (button.link == 4) return 4.4 + flag;
                    if (button.link == 5) return 4.3 + flag;
                  }
                  if (name == 'shan') {
                    if (player.hp <= 2) return 2;
                    if (Math.random() > 0.8) return 1;
                  }
                  if (evt.type == 'dying') {
                    if (get.attitude(player, evt.dying) < 2) return false;
                    if (name == 'jiu') return 2.1;
                    return 1.9;
                  }
                  if (evt.type == 'phase') {
                    if (name == 'jiu') return 0;
                    if (name == 'tao') {
                      if (player.hp == 1) return 1;
                      if (player.hp == 2 && player.countCards("h") >= 3) return 1;
                      return 0;
                    }
                    if (name == 'sha' && Math.random() > 0.6) return player.getUseValue({
                      name: name,
                      nature: button.link[3],
                      isCard: true
                    });
                    return 0;
                  }
                  if (Math.random() > 0.8) return 1;
                  return 0;
                },
                backup: function(links, player) {
                  if (typeof links[1] == 'number') links.reverse();
                  var equip = links[0];
                  var name = links[1][2];
                  var nature = links[1][3];
                  return {
                    filterCard: function() {
                      return false
                    },
                    selectCard: -1,
                    equip: equip,
                    viewAs: {
                      name: name,
                      nature: nature,
                      isCard: true,
                    },
                    popname: true,
                    precontent: function() {
                      player.logSkill('jiefan3d8');
                      player.disableEquip(lib.skill.jiefan3d8_backup.equip);
                      var card = player.getEquip(lib.skill.jiefan3d8_backup.equip);
                      if (card) player.draw(2);
                      delete event.result.skill;
                    },
                  }
                },
                prompt: function(links, player) {
                  if (typeof links[1] == 'number') links.reverse();
                  var equip = 'equip' + links[0];
                  var name = links[1][2];
                  var nature = links[1][3];
                  return '废除自己的' + get.translation(equip) + '栏，视为使用' + (get.translation(nature) || '') + get.translation(name);
                },
              },
              ai: {
                respondSha: true,
                respondShan: true,
                skillTagFilter: function(player, tag, arg) {
                  if (arg == 'respond') return false;
                  if (player.countDisabled() >= 5) return false;
                  return true;
                },
                order: 1,
                result: {
                  player: 1,
                },
              },
            },

            gongqi3d8: {
              mod: {
                globalFrom: function(from, to, distance) {
                  return distance - from.countDisabled();
                },
              },
            },

            qianfu3d8: {
              audio: "fuzhong",
              forced: true,
              trigger: {
                player: "phaseZhunbeiBegin",
              },
              filter: function(event, player) {
                return player.hp == 1 || player.countCards('h') == 1;
              },
              content: function() {
                "step 0"
                player.draw(3);
                "step 1"
                var evt = _status.event.getParent('phase');
                if (evt) {
                  game.resetSkills();
                  _status.event = evt;
                  _status.event.finish();
                  _status.event.untrigger(true);
                }
              },
            },

            zhuci3d8: {
              audio: "XS_juebi",
              trigger: {
                global: "phaseDiscardBegin",
              },
              filter: function(event, player) {
                return event.player != player && !player.hasSkill("zhuci3d8_null");
              },
              check: function(event, player) {
                var cards = player.getCards("h");
                if (cards.length == 0) return false;
                var card = 0;
                var sha = 0;
                var tao = 0;
                var wuzhong = 0;
                var good = 0;
                for (var i = 0; i < cards.length; i++) {
                  var card = cards[i];
                  if (card.name == 'wuzhong' || card.name == 'zengbing') wuzhong = 1;
                  if (card.name == 'tao') tao = 1;
                  if (lib.filter.cardEnabled(card, player) && lib.filter.cardUsable(card, player) && game.hasPlayer(function(current) {
                      return player.canUse(card, current) && lib.filter.targetEnabled2(card, player, current);
                    }) && player.getUseValue(card) > 0) {
                    if (get.value(card) >= 7) good = 1;
                    card = 1;
                  }
                  if (card.name == 'sha') sha = 2;
                }
                if (player.canUse('sha', event.player) && get.effect(event.player, {
                    name: 'sha'
                  }, player, player) > 0 && sha == 2) sha = 1;
                if (sha == 1 && !event.player.getEquip("bagua")) return true;
                if (player.isDamaged() && tao == 1) return true;
                if (wuzhong == 1) return true;
                if (get.attitude(player, event.player) < 0) return (good == 1 || (card == 1 && Math.random() > 0.5));
                return good == 1 && Math.random() > 0.5;
              },
              content: function() {
                "step 0"
                player.line(trigger.player, "red");
                player.storage.zhuci3d8_player = trigger.player;
                trigger.player.storage.zhuci3d8_disable_cards = [];
                event.count = game.filterPlayer().length;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  players[i].storage.zhuci3d8_hp = players[i].hp;
                  players[i].storage.zhuci3d8_cnt = players[i].countCards("h");
                }
                if (trigger.player.countCards("h") > trigger.player.getHandcardLimit()) {
                  var cnt = trigger.player.countCards("h") - trigger.player.getHandcardLimit();
                  trigger.player.chooseCard('诛刺：选择超出手牌上限的牌', 'he', cnt, true)
                    .set('ai', function(card) {
                      if (player.countCards("h") == 0 || get.attitude(player, trigger.player) >= 0) return 20 - get.useful(card);
                      var cards = ui.selected.cards;
                      var shan = 0;
                      var tao = 0;
                      var jiu = 0;
                      for (var i = 0; i < cards.length; i++) {
                        if (cards[i].name == 'shan') shan = 1;
                        if (cards[i].name == 'tao') tao = 1;
                        if (cards[i].name == 'jiu') jiu = 1;
                      }
                      if (player.canUse('sha', trigger.player) && get.effect(trigger.player, {
                          name: 'sha'
                        }, player, player) > 0) {
                        if (card.name == 'shan' && shan == 0) {
                          if (!trigger.player.getEquip("bagua")) return 100;
                        }
                      }
                      var danger = 0;
                      var urgent = 0;
                      var players = game.filterPlayer();
                      for (var i = 0; i < players.length; i++) {
                        if (get.attitude(trigger.player, players[i]) <= 0) continue;
                        if (players[i].hp == 1 && get.distance(player, players[i], 'attack') <= 1) {
                          if (players[i] != trigger.player) danger += 1;
                          if (players[i] == trigger.player) urgent = 1;
                        }
                      }
                      if (danger > 0) {
                        if (danger > 0 && tao == 0 && card.name == 'tao') return 70;
                        if (urgent > 0 && tao == 0 && jiu == 0 && card.name == 'tao') return 70;
                        if (urgent > 0 && tao == 0 && jiu == 0 && card.name == 'jiu') return 50;
                      }
                      return 20 - get.useful(card);
                    });
                }
                "step 1"
                if (result.bool) {
                  trigger.player.storage.zhuci3d8_disable_cards = result.cards;
                  event.cards = result.cards;
                }
                player.chooseToUse();
                "step 2"
                var flag = 0;
                if (event.count != game.filterPlayer().length) flag = 1;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i] == player) continue;
                  if (players[i].storage.zhuci3d8_hp != players[i].hp) flag = 1;
                  if (players[i].storage.zhuci3d8_cnt != players[i].countCards("h")) flag = 1;
                }
                if (flag == 1) player.addTempSkill("zhuci3d8_null", "roundStart");
                "step 3"
                if (trigger.player.storage.zhuci3d8_disable_cards.length == 0) event.finish();
                var cards = [];
                var handcards = trigger.player.getCards("h");
                for (var i = 0; i < handcards.length; i++) {
                  if (trigger.player.storage.zhuci3d8_disable_cards.contains(handcards[i])) cards.push(handcards[i]);
                }
                trigger.player.discard(cards);
              },
              group: ["zhuci3d8_debuff", "zhuci3d8_remove"],
              subSkill: {
                debuff: {
                  forced: true,
                  popup: false,
                  trigger: {
                    player: "useCard",
                  },
                  filter: function(event, player) {
                    return event.parent.parent.name == 'zhuci3d8';
                  },
                  content: function() {
                    player.storage.zhuci3d8_player.addSkill("zhuci3d8_disable");
                  },
                },
                remove: {
                  forced: true,
                  popup: false,
                  trigger: {
                    player: "useCardAfter",
                  },
                  filter: function(event, player) {
                    return event.parent.parent.name == 'zhuci3d8';
                  },
                  content: function() {
                    player.storage.zhuci3d8_player.removeSkill("zhuci3d8_disable");
                  },
                },
              },
              ai: {
                "directHit_ai": true,
                skillTagFilter: function(player, tag, arg) {
                  if (!arg.target.hasSkill('zhuci3d8_disable')) return false;
                  var cnt = arg.target.countCards("h") - arg.target.getHandcardLimit();
                  if (cnt <= 0) return true;
                  return Math.random() > Math.min(cnt, 3) * 0.3;
                },
              },
            },

            zhuci3d8_disable: {
              forced: true,
              mod: {
                cardEnabled: function(card, player) {
                  if (!card.cards) return;
                  if (player.storage.zhuci3d8_disable_cards.length == 0) return false;
                  if (player.storage.zhuci3d8_disable_cards.contains(card.cards[0])) {
                    return;
                  }
                  return false;
                },
                cardUsable: function(card, player) {
                  if (!card.cards) return;
                  if (player.storage.zhuci3d8_disable_cards.length == 0) return false;
                  if (player.storage.zhuci3d8_disable_cards.contains(card.cards[0])) {
                    return;
                  }
                  return false;
                },
                cardRespondable: function(card, player) {
                  if (!card.cards) return;
                  if (player.storage.zhuci3d8_disable_cards.length == 0) return false;
                  if (player.storage.zhuci3d8_disable_cards.contains(card.cards[0])) {
                    return;
                  }
                  return false;
                },
                cardSavable: function(card, player) {
                  if (!card.cards) return;
                  if (player.storage.zhuci3d8_disable_cards.length == 0) return false;
                  if (player.storage.zhuci3d8_disable_cards.contains(card.cards[0])) {
                    return;
                  }
                  return false;
                },
              },
            },

            zhuci3d8_null: {

            },

            pimi3d8: {
              audio: "jlsg_jiwu",
              trigger: {
                source: "damageEnd",
              },
              frequent: true,
              filter: function(event, player) {
                if (event._notrigger.contains(event.player)) return false;
                return event.card && event.card.name == 'sha' && !player.hasSkill("pimi3d8_buff_juedou");
              },
              content: function() {
                player.addTempSkill('pimi3d8_buff_juedou', {
                  player: 'phaseBegin'
                });
                player.markSkill('pimi3d8_buff_juedou');
              },
              group: ["pimi3d8_juedou"],
              subSkill: {
                juedou: {
                  audio: "jlsg_jiwu",
                  trigger: {
                    source: "damageEnd",
                  },
                  frequent: true,
                  filter: function(event, player) {
                    if (event._notrigger.contains(event.player)) return false;
                    return event.card && event.card.name == 'juedou' && !player.hasSkill("pimi3d8_buff_sha");
                  },
                  content: function() {
                    player.addTempSkill('pimi3d8_buff_sha', {
                      player: 'phaseBegin'
                    });
                    player.markSkill('pimi3d8_buff_sha');
                  },
                },
              },
            },

            pimi3d8_buff_juedou: {
              audio: "jlsg_jiwu",
              marktext: "披",
              intro: {
                content: function(storage, player, skill) {
                  return '【决斗】伤害+1';
                },
              },
              trigger: {
                source: "damageBegin1",
              },
              filter: function(event) {
                return event.card && (event.card.name == 'juedou') && event.notLink();
              },
              forced: true,
              content: function() {
                trigger.num++;
              },
              ai: {
                damageBonus: true,
              },
            },

            pimi3d8_buff_sha: {
              audio: "jlsg_jiwu",
              marktext: "披",
              intro: {
                content: function(storage, player, skill) {
                  return '【杀】伤害+1';
                },
              },
              trigger: {
                source: "damageBegin1",
              },
              filter: function(event) {
                return event.card && (event.card.name == 'sha') && event.notLink();
              },
              forced: true,
              content: function() {
                trigger.num++;
              },
              ai: {
                damageBonus: true,
              },
            },

            baonu3d8: {
              group: ["baonu3d8_sha", "baonu3d8_juedou"],
            },

            baonu3d8_sha: {
              audio: "jlsg_sheji",
              enable: ["chooseToUse"],
              filterCard: true,
              selectCard: function() {
                return -1;
              },
              position: "h",
              viewAs: {
                name: "sha",
              },
              filter: function(event, player) {
                return player.countCards('h') > 0;
              },
              check: function(card) {
                if (card.name == 'sha') return -1;
                return 6 - get.useful(card);
              },
              ai: {
                order: function() {
                  return get.order({
                    name: 'sha'
                  }) + 0.1;
                },
                respondSha: true,
                skillTagFilter: function(player) {
                  return player.countCards('h') > 0;
                },
                canLink: function(player, target, card) {
                  if (!target.isLinked() && !player.hasSkill('wutiesuolian_skill')) return false;
                  if (target.mayHaveShan() && !player.hasSkillTag('directHit_ai', true, {
                      target: target,
                      card: card,
                    }, true)) return false;
                  if (player.hasSkill('jueqing') || player.hasSkill('gangzhi') || target.hasSkill('gangzhi')) return false;
                  return true;
                },
                basic: {
                  useful: [5, 3, 1],
                  value: [5, 3, 1],
                },
                result: {
                  player: function(player) {
                    var num = 0;
                    var cards = player.getCards('h');
                    if (cards.length >= 3 && player.hp >= 3) return -10;
                    for (var i = 0; i < cards.length; i++) {
                      if (cards[i].name == 'sha') return -100;
                      num += Math.max(0, get.value(cards[i], player, 'raw'));
                    }
                    num /= cards.length;
                    num *= Math.min(cards.length, player.hp);
                    if (12 - num < 0) return -100;
                    return 0;
                  },
                  target: function(player, target, card, isLink) {
                    var eff = function() {
                      if (!isLink && (player.hasSkill('jiu') || player.hasSkill("pimi3d8_buff_sha"))) {
                        if (!target.hasSkillTag('filterDamage', null, {
                            player: player,
                            card: card,
                            jiu: true,
                          })) {
                          if (get.attitude(player, target) > 0) {
                            return -7;
                          } else {
                            return -4;
                          }
                        }
                        return -0.5;
                      }
                      return -1.5;
                    }();
                    if (!isLink && target.mayHaveShan() && !player.hasSkillTag('directHit_ai', true, {
                        target: target,
                        card: card,
                      }, true)) return eff / 1.2;
                    return eff;
                  },
                },
                tag: {
                  respond: 1,
                  respondShan: 1,
                  damage: function(card) {
                    if (card.nature == 'poison') return;
                    return 1;
                  },
                  natureDamage: function(card) {
                    if (card.nature) return 1;
                  },
                  fireDamage: function(card, nature) {
                    if (card.nature == 'fire') return 1;
                  },
                  thunderDamage: function(card, nature) {
                    if (card.nature == 'thunder') return 1;
                  },
                  poisonDamage: function(card, nature) {
                    if (card.nature == 'poison') return 1;
                  },
                },
              }
            },

            baonu3d8_juedou: {
              audio: "jlsg_sheji",
              enable: ["chooseToUse"],
              filterCard: true,
              selectCard: function() {
                return -1;
              },
              position: "h",
              viewAs: {
                name: "juedou",
              },
              filter: function(event, player) {
                return player.countCards('h') > 0;
              },
              check: function(card) {
                if (card.name == 'juedou') return -1;
                return 6 - get.useful(card);
              },
              ai: {
                order: function() {
                  return 1;
                },
                skillTagFilter: function(player) {
                  return player.countCards('h') > 0;
                },
                result: {
                  player: function(player) {
                    var num = 0;
                    var cards = player.getCards('h');
                    if (cards.length >= 3 && player.hp >= 3) return -10;
                    for (var i = 0; i < cards.length; i++) {
                      if (cards[i].name == 'juedou') return -100;
                      num += Math.max(0, get.value(cards[i], player, 'raw'));
                    }
                    num /= cards.length;
                    num *= Math.min(cards.length, player.hp);
                    if (12 - num < 0) return -100;
                    return 0;
                  },
                  target: function(player, target, card, isLink) {
                    if (target.hp == 1 && get.damageEffect(target, player, player) > 0) {
                      if (target.countCards("h") <= 1) return -8;
                      if (target.countCards("h") <= 2) return -6;
                      return 0;
                    }
                    if (target.hp <= 2 && get.damageEffect(target, player, player) > 0 && player.hasSkill("pimi3d8_buff_juedou")) {
                      if (target.countCards("h") <= 1) return -8;
                      if (target.countCards("h") <= 2) return -6;
                      return 0;
                    }
                    if (target.countCards("h") == 0 && get.damageEffect(target, player, player) > 0) return -8;
                    return 0;
                  },
                },
              }
            },

            tongshe3d8: {
              mod: {
                aiOrder: function(player, card, num) {
                  if (get.tag(card, 'multitarget')) return num - 5;
                },
              },
              audio: "jlsg_quanlue",
              trigger: {
                player: "useCardToBegin",
              },
              filter: function(event, player) {
                //if(event.getParent().name=='XS_xingmie') return false; 
                if (event.card.name != 'sha' && get.type(event.card) != 'trick') return false;
                if (event.targets.length != 1) return false;
                if (event.targets[0] == player) return false;
                if (event.targets[0].countCards("he") == 0) return false;
                return true;
              },
              check: function(event, player) {
                var att = get.attitude(player, event.targets[0]);
                if (att >= 0) return false;
                if (get.damageEffect(event.targets[0], player, player) <= 0) return false;
                if (player.hasSkill('jiu') && event.card.name == 'sha' && !event.targets[0].getEquip('bagua')) {
                  if (event.targets[0].countCards("h") == 0) return false;
                  if (event.targets[0].countCards("h") == 1) return Math.random() > 0.5;
                  if (event.targets[0].countCards("h") == 2) return Math.random() > 0.3;
                  return true;
                }
                var cards = player.getCards("h");
                if (cards.length == 0) return false;
                if (cards.length >= 3) return true;
                for (var i = 0; i < cards.length; i++) {
                  var card = cards[i];
                  if (lib.filter.cardEnabled(card, player) && lib.filter.cardUsable(card, player) &&
                    player.canUse(card, event.targets[0]) && lib.filter.targetEnabled2(card, player, event.targets[0]) &&
                    get.effect(event.targets[0], card, player, player) > 0) return true;
                }
                if (cards.length == 1) {
                  if (player.getCardUsable('sha') == 0) return false;
                  if (get.value(event.card) >= 8) return Math.random() > 0.9;
                  return Math.random() > 0.7;
                }
                if (player.getCardUsable('sha') == 0) return Math.random() > 0.8;
                if (get.value(event.card) >= 8) return Math.random() > 0.6;
                return Math.random() > 0.5;
              },
              content: function() {
                "step 0"
                trigger.cancel();
                event.target = trigger.targets[0];
                event.target.chooseControl(["同意", "拒绝"], true)
                  .set('prompt', '统慑：是否令' + get.translation(player) + '获得你一张牌？').ai = function() {
                    var ecards = event.target.getCards("e");
                    var hcards = event.target.getCards("e");
                    var cards_1 = player.getCards("h");
                    var ev = 0;
                    var hv = 0;
                    if (get.damageEffect(event.target, player, event.target) >= 0) return "同意";
                    if (cards_1.length == 0) return "拒绝";
                    for (var i = 0; i < ecards.length; i++) {
                      if (get.value(ecards[i]) >= 8) ev += 1;
                    }
                    for (var i = 0; i < hcards.length; i++) {
                      if (get.value(hcards[i]) >= 8) hv += 1;
                    }
                    if (cards_1.length >= 3) {
                      if (player.getCardUsable('sha') > 0) return "同意";
                      if (ev || hv / (hcards.length + 0.0) >= 0.5) {
                        if (event.target.storage.tongshe3d8 == 0) return "拒绝";
                        return "同意";
                      }
                      if (event.target.hp <= 2) return "同意";
                      if (Math.random() > 0.6) return "拒绝";
                      return "同意";
                    }
                    if (player.getCardUsable('sha') == 0) {
                      if (Math.random() > 0.3) return "拒绝";
                      return "同意";
                    }
                    if (ev || hv / (hcards.length + 0.0) >= 0.5) {
                      if (event.target.storage.tongshe3d8 >= 0 && Math.random() > 0.5) return "同意";
                      return "拒绝";
                    }
                    if (event.target.hp <= 1) return "同意";
                    if (event.target.hp <= 2) {
                      if (Math.random() > 0.5) return "拒绝";
                      return "同意";
                    }
                    if (Math.random() > 0.3) return "拒绝";
                    return "同意";
                  };

                "step 1"
                if (result.control) {
                  if (result.control == '同意') {
                    game.log(event.target, '同意令', player, '获得一张牌');
                    player.gainPlayerCard(true, event.target, 'he');
                  } else {
                    game.log(event.target, '拒绝令', player, '获得一张牌');
                    event.target.storage.tongshe3d8 += 1;
                  }
                }
              },
              group: ["tongshe3d8_init"],
              subSkill: {
                init: {
                  trigger: {
                    player: "phaseUseBegin",
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    var players = game.filterPlayer();
                    for (var i = 0; i < players.length; i++) {
                      players[i].storage.tongshe3d8 = 0;
                      players[i].addTempSkill("tongshe3d8_buff", "phaseUseAfter");
                    }
                  },
                  sub: true,
                },
              },
            },

            tongshe3d8_buff: {
              popup: false,
              forced: true,
              trigger: {
                target: "useCardToBefore",
              },
              filter: function(event, player) {
                if (event.player == player) return false;
                if (event.player != _status.currentPhase) return false;
                if (!event.player.hasSkill("tongshe3d8")) return false;
                if (!player.storage.tongshe3d8 || player.storage.tongshe3d8 == 0) return false;
                return true;
              },
              content: function() {
                trigger.player.logSkill("tongshe3d8", player);
                player.damage(trigger.player, player.storage.tongshe3d8, 'nocard');
              },
              ai: {
                effect: {
                  target: function(card, player, target) {
                    if (!player.hasSkill("tongshe3d8")) return;
                    if (target.countCards("he") == 0) return;
                    if (target.storage.tongshe3d8 == 0) {
                      if (get.attitude(player, target) < 0) return [1, -1];
                      return;
                    }
                    return [1, -target.storage.tongshe3d8];
                  },
                },
              },
            },

            shenshi3d8: {
              audio: "jlsg_guicai",
              trigger: {
                player: "useCardBegin",
              },
              filter: function(event, player) {
                if (event.parent.name == 'bigong3d8') return false;
                if (!player.countCards('h')) return false;
                var info = get.info(event.card);
                if (info.type != 'trick' && info.type != 'basic') return false;
                if (info.multitarget) return false;
                var cards = player.getCards("h");
                var usable = 0;
                var nousable = 0;
                for (var i = 0; i < cards.length; i++) {
                  var card = cards[i];
                  var flag = 0;
                  if (event.card.cards && event.card.cards.length > 0) {
                    for (var j = 0; j < event.card.cards.length; j++) {
                      if (card == event.card.cards[j]) flag = 1;
                    }
                  }
                  if (flag == 1) continue;
                  if (!game.hasPlayer(function(current) {
                      return player.canUse(card, current);
                    }) || !lib.filter.cardUsable(card, player) || (card.name == event.card.name && player.getCardUsable(card) <= 1)) nousable += 1;
                  else usable += 1;
                }

                if (event.targets.length > 1 && nousable > 0) return true;
                return game.hasPlayer(function(current) {
                  return !event.targets.contains(current) && lib.filter.targetEnabled2(event.card, event.player, current);
                }) && usable > 0;
              },
              direct: true,
              content: function() {
                'step 0'
                var cards = player.getCards("h");
                var usable = 0;
                var nousable = 0;
                for (var i = 0; i < cards.length; i++) {
                  var card = cards[i];
                  var flag = 0;
                  if (trigger.card.cards && trigger.card.cards.length > 0) {
                    for (var j = 0; j < trigger.card.cards.length; j++) {
                      if (card == trigger.card.cards[j]) flag = 1;
                    }
                  }
                  if (flag == 1) continue;
                  if (!game.hasPlayer(function(current) {
                      return player.canUse(card, current);
                    }) || !lib.filter.cardUsable(card, player) || (card.name == trigger.card.name && player.getCardUsable(card) <= 1)) nousable += 1;
                  else usable += 1;
                }
                var bool1 = (trigger.targets.length > 1 && nousable > 0);
                var bool2 = game.hasPlayer(function(current) {
                  return !trigger.targets.contains(current) && lib.filter.targetEnabled2(trigger.card, trigger.player, current);
                }) && usable > 0;
                if (bool1 && bool2) {
                  player.chooseControlList(true, get.prompt('shenshi3d8'), [
                    '移出任意张牌 ，并为' + get.translation(trigger.card) + '增加等量的目标',
                    '弃置任意张牌 ，并为' + get.translation(trigger.card) + '减少等量的目标'
                  ], function(event, player) {
                    if (_status.event.add) return 0;
                    return 1;
                  }).set('add', get.effect(player, trigger.card, trigger.player, player) >= 0);
                } else if (bool2) {
                  event.type = 'add';
                  event.goto(2);
                  event.unchosen = true;
                } else {
                  event.type = 'remove';
                  event.goto(2);
                  event.unchosen = true;
                }
                'step 1'
                if (result.control == 'cancel2') {
                  event.finish();
                } else if (result.index == 1) {
                  event.type = 'remove';
                } else {
                  event.type = 'add';
                }
                'step 2'
                if (event.type == 'add') {
                  var num = game.countPlayer(function(current) {
                    return !trigger.targets.contains(current) && lib.filter.targetEnabled2(trigger.card, trigger.player, current);
                  });
                  var num2 = game.countPlayer(function(current) {
                    if (!trigger.targets.contains(current) && lib.filter.targetEnabled2(trigger.card, trigger.player, current)) {
                      return get.effect(current, trigger.card, player, player) > 0;
                    }
                    return false;
                  });
                  if (num2 > 2) num2 = 2;
                  player.chooseCardTarget({
                    selectCard: [1, num],
                    selectTarget: function() {
                      return ui.selected.cards.length;
                    },
                    filterCard: function(card) {
                      var flag = 0;
                      if (trigger.card.cards && trigger.card.cards.length > 0) {
                        for (var j = 0; j < trigger.card.cards.length; j++) {
                          if (card == trigger.card.cards[j]) flag = 1;
                        }
                      }
                      if (flag == 1) return false;
                      if (!game.hasPlayer(function(current) {
                          return player.canUse(card, current);
                        }) || !lib.filter.cardUsable(card, player) || (card.name == trigger.card.name && player.getCardUsable(card) <= 1)) return false;
                      return true;
                    },
                    position: 'h',
                    prompt: event.unchosen ? get.prompt('shenshi3d8') : null,
                    prompt2: '移出任意张可以使用的牌，并为' + get.translation(trigger.card) + '增加等量的目标',
                    filterTarget: function(card, player, target) {
                      return !trigger.targets.contains(target) && lib.filter.targetEnabled2(trigger.card, trigger.player, target);
                    },
                    ai1: function(card) {
                      if (ui.selected.cards.length >= num2) return 0;
                      return get.value(trigger.card) - get.value(card) - 1;
                    },
                    ai2: function(target) {
                      var trigger = _status.event.getTrigger();
                      return get.effect(target, trigger.card, trigger.player, _status.event.player);
                    }
                  });
                } else {
                  var num = trigger.targets.length - 1;
                  var num2 = game.countPlayer(function(current) {
                    if (trigger.targets.contains(current)) {
                      return get.effect(current, trigger.card, player, player) < 0;
                    }
                    return false;
                  });
                  if (num2 > 2) num2 = 2;
                  player.chooseCardTarget({
                    selectCard: [1, num],
                    selectTarget: function() {
                      return ui.selected.cards.length;
                    },
                    filterCard: function(card) {
                      var flag = 0;
                      if (trigger.card.cards && trigger.card.cards.length > 0) {
                        for (var j = 0; j < trigger.card.cards.length; j++) {
                          if (card == trigger.card.cards[j]) flag = 1;
                        }
                      }
                      if (flag == 1) return false;
                      if (!game.hasPlayer(function(current) {
                          return player.canUse(card, current);
                        }) || !lib.filter.cardUsable(card, player) || (card.name == trigger.card.name && player.getCardUsable(card) <= 1)) return true;
                      return false;
                    },
                    prompt: event.unchosen ? get.prompt('shenshi3d8') : null,
                    prompt2: '弃置任意张牌，并为' + get.translation(trigger.card) + '减少等量的目标',
                    filterTarget: function(card, player, target) {
                      return trigger.targets.contains(target);
                    },
                    ai1: function(card) {
                      if (!player.needsToDiscard(ui.selected.cards.length)) return 0;
                      if (ui.selected.cards.length >= num2) return 0;
                      return Math.max(5, get.value(trigger.card)) - get.value(card) - 1;
                    },
                    ai2: function(target) {
                      var trigger = _status.event.getTrigger();
                      return -get.effect(target, trigger.card, trigger.player, _status.event.player);
                    }
                  });
                }
                'step 3'
                if (result.bool) {
                  if (!event.isMine()) game.delayx();
                  event.targets = result.targets.slice(0);
                  event.cards = result.cards.slice(0);
                } else {
                  event.finish();
                }
                'step 4'
                player.logSkill('shenshi3d8', event.targets);
                if (event.type == 'add') {
                  player.addSkill('shenshi3d82');
                  player.lose(event.cards, ui.special, 'toStorage');
                  player.storage.shenshi3d82 = event.cards;
                  game.log(player, '移出了' + get.cnNumber(event.cards.length) + '张牌');
                  player.markSkill('shenshi3d82');
                } else player.discard(event.cards).delay = false;
                if (event.type == 'add') {
                  for (var i = 0; i < event.targets.length; i++) {
                    game.log(player, '选择了', event.targets[i], '为', trigger.card, '的额外对象');
                    trigger.targets.push(event.targets[i]);
                  }
                } else {
                  for (var i = 0; i < event.targets.length; i++) {
                    game.log(player, '取消了', event.targets[i], '为', trigger.card, '的效果');
                    trigger.targets.remove(event.targets[i]);
                  }
                }
              },
              ai: {
                expose: 0.2,
              },
            },

            shenshi3d82: {
              init: function(player, skill) {
                if (!player.storage[skill]) player.storage[skill] = [];
              },
              trigger: {
                global: "phaseEnd",
              },
              forced: true,
              charlotte: true,
              filter: function(event, player) {
                return player.storage.shenshi3d82 && player.storage.shenshi3d82.length > 0;
              },
              content: function() {
                'step 0'
                game.log(player, '收回了' + get.cnNumber(player.gain(player.storage.shenshi3d82, 'draw', 'fromStorage').cards.length) + '张牌');
                player.storage.shenshi3d82.length = 0;
                'step 1'
                delete player.storage.shenshi3d82;
                player.removeSkill('shenshi3d82');
              },
              intro: {
                onunmark: "throw",
                content: "cardCount",
              },
              marktext: "审"
            },

            bigong3d8: {
              audio: "jlsg_langgu",
              mark: true,
              unique: true,
              limited: true,
              skillAnimation: true,
              animationColor: "fire",
              trigger: {
                player: "useCard",
              },
              priority: -10,
              filter: function(event, player) {
                return !player.storage.bigong3d8 && event.targets.length > 1;
              },
              init: function(player) {
                player.storage.bigong3d8 = false;
              },
              check: function(event, player) {
                if (event.targets.length < 4) return false;
                for (var i = 0; i < event.targets.length; i++) {
                  if (get.effect(event.targets[i], event.card, player, player) >= 1) return true;
                }
                return false;
              },
              content: function() {
                'step 0'
                player.awakenSkill('bigong3d8');
                player.storage.bigong3d8 = true;
                'step 1'
                event.nm = trigger.targets.length;
                player.chooseTarget('令你使用的' + get.translation(trigger.card) + '仅对其中一名目标结算' + event.nm + '次，或令其失去所有技能', true, function(card, player, target) {
                  var trigger = _status.event.getTrigger();
                  return trigger.targets.contains(target);
                }).ai = function(target) {
                  var trigger = _status.event.getTrigger();
                  var eff = get.effect(target, trigger.card, player, player);
                  return eff;
                }
                'step 2'
                if (result.bool) {
                  event.tar = result.targets[0];
                  player.line(event.tar, "red");
                  event.tar.chooseControl().set('choiceList', [
                    '令' + get.translation(trigger.card) + '对你结算' + event.nm + '次',
                    '失去所有技能',
                  ]).set('ai', function() {
                    var eff = get.effect(event.tar, trigger.card, player, event.tar);
                    if (eff >= 0) return 0;
                    if (trigger.card.name == 'nanmian' || trigger.card.name == 'wanjian' && player.getEquip("tengjia")) return 0;
                    if (trigger.card.name == 'sha' || trigger.card.name == 'wanjian') {
                      if (event.tar.countCards('h', {
                          name: 'shan'
                        }) + event.tar.countCards('h', {
                          name: 'tao'
                        }) + event.tar.countCards('h', {
                          name: 'jiu'
                        }) +
                        event.tar.hp > event.nm) return 0;
                      if (event.tar.countCards('h', {
                          name: 'shan'
                        }) + event.tar.countCards('h', {
                          name: 'tao'
                        }) + event.tar.countCards('h', {
                          name: 'jiu'
                        }) +
                        event.tar.hp >= event.nm - 1 && player.getEquip("bagua")) return 0;
                      if (event.tar.hasSkillTag('respondShan') && event.target.countCards('h') + event.tar.hp > event.num) return 0;
                      return 1;
                    }
                    if (trigger.card.name == 'juedou' || trigger.card.name == 'nanman') {
                      if (event.tar.countCards('h', {
                          name: 'sha'
                        }) + event.tar.countCards('h', {
                          name: 'tao'
                        }) + event.tar.countCards('h', {
                          name: 'jiu'
                        }) +
                        event.tar.hp > event.nm) return 0;
                      if (event.tar.hasSkillTag('respondSha') && event.target.countCards('h') + event.tar.hp > event.num) return 0;
                      return 1;
                    }
                    return 0;
                  });
                }
                'step 3'
                if (result.index == 0) {
                  game.log(event.tar, '选择被' + get.translation(trigger.card) + '结算' + event.nm + '次');
                  trigger.targets = [];
                  trigger.targets.push(event.tar);
                  for (var i = 0; i < event.nm - 1; i++) {
                    player.useCard(trigger.card, event.tar, false);
                  }
                } else if (result.index == 1) {
                  game.log(event.tar, '选择失去了所有技能');
                  event.tar.clearSkills();
                } else event.finish();
              },
              ai: {
                expose: 0.3,
                effect: {
                  player: function(card, player, target, current) {
                    var check = game.hasPlayer(function(current) {
                      return player.canUse(card, current) && lib.filter.targetEnabled2(card, player, current) && !current.getEquip("tengjia");
                    });
                    if (get.tag(card, 'multineg') && check) return [0, 3];
                  },
                },
              },
              intro: {
                content: "limited",
              },
            },

            ximeng3d8: {
              audio: "jlsg_xiemu",
              derivation: "hehe3d8",
              trigger: {
                global: ["roundStart"],
              },
              direct: true,
              content: function() {
                'step 0'
                player.chooseTarget('指定一名其他角色，其于本轮内视为拥有“和合”', function(card, player, target) {
                  return !target.hasSkill("hehe3d8") && target != player;
                }).ai = function(target) {
                  return get.attitude(player, target);
                }
                'step 1'
                if (result.bool) {
                  player.logSkill('ximeng3d8', result.targets);
                  result.targets[0].storage.hehe3d8_player = player;
                  result.targets[0].addTempSkill("hehe3d8", "roundStart");
                }
              }

            },

            hehe3d8: {
              trigger: {
                global: "useSkillAfter",
              },
              forced: true,
              //audio:"jlsg_xiemu",
              filter: function(event, player) {
                //if(!lib.translate[event.skill+'_info']||!lib.translate[event.skill+'_info'].length) return false;
                if (event.skill == '_chongzhu' || event.skill == 'muniu_skill') return false;
                var info = get.info(event.skill);
                if (info.forced || info.juexingji) return false;
                return event.player == player.storage.hehe3d8_player || event.player == player;
              },
              content: function() {
                player.line(player.storage.hehe3d8_player, "green");
                player.storage.hehe3d8_player.line(player, "green");
                if (trigger.player == player) player.storage.hehe3d8_player.draw();
                else player.draw();
              },
            },

            shiduan3d8: {
              audio: "jlsg_yalv",
              mark: true,
              locked: true,
              zhuanhuanji: true,
              marktext: "识",
              intro: {
                content: function(storage, player, skill) {
                  var str = player.storage.shiduan3d8 ? '出牌阶段限一次，你可以令一名角色于其下个出牌阶段内使用【杀】的次数上限、使用以“出牌阶段限一次”开始的技能次数上限分别：-1、+1' : '你可以令一名角色于其下个出牌阶段内使用【杀】的次数上限、使用以“出牌阶段限一次”开始的技能次数上限分别：+1、-1';
                  return str;
                },
              },
              enable: "phaseUse",
              usable: 1,
              content: function() {
                'step 0'
                if (player.storage.shiduan3d8 == true) {
                  player.storage.shiduan3d8 = false;
                  player.chooseTarget('指定一名其他角色，其于本轮内使用【杀】的次数上限、使用以“出牌阶段限一次”开始的技能次数上限分别：-1、+1', function(card, player, target) {
                    return !target.hasSkill("shiduan3d8_buff1");
                  }).ai = function(target) {
                    var skills = target.get('s', false, false);
                    var att = get.attitude(player, target);
                    var count = 0;
                    for (i = 0; i < skills.length; i++) {
                      var info = lib.skill[skills[i]];
                      if (!info) continue;
                      if (!lib.translate[skills[i]]) continue;
                      if (!lib.translate[skills[i] + '_info']) continue;
                      if (info.enable && info.enable == 'phaseUse' && info.usable && info.usable == 1) {
                        count += 1;
                      }
                    }
                    if (count == 0) return -att + 0.1;
                    return att * count + 0.1;
                  }
                } else {
                  player.storage.shiduan3d8 = true;
                  player.chooseTarget('指定一名其他角色，其于本轮内使用【杀】的次数上限、使用以“出牌阶段限一次”开始的技能次数上限分别：+1、-1', function(card, player, target) {
                    return !target.hasSkill("shiduan3d8_buff2");
                  }).ai = function(target) {
                    var skills = target.get('s', false, false);
                    var att = get.attitude(player, target);
                    var count = 0;
                    for (i = 0; i < skills.length; i++) {
                      var info = lib.skill[skills[i]];
                      if (!info) continue;
                      if (!lib.translate[skills[i]]) continue;
                      if (!lib.translate[skills[i] + '_info']) continue;
                      if (info.enable && info.enable == 'phaseUse' && info.usable && info.usable == 1) {
                        count += 1;
                      }
                    }
                    if (count == 0) return att + 0.1;
                    return -att * count + 0.1;
                  }
                };
                'step 1'
                if (result.bool) {
                  player.logSkill('shiduan3d8', result.targets);
                  if (player.storage.shiduan3d8 == true) {
                    result.targets[0].addTempSkill("shiduan3d8_buff2", {
                      player: "phaseEnd"
                    });
                    var skills = result.targets[0].get('s', false, false);
                    result.targets[0].storage.shiduan3d8_buff2_skills = [];
                    for (i = 0; i < skills.length; i++) {
                      var info = lib.skill[skills[i]];
                      if (!info) continue;
                      if (!lib.translate[skills[i]]) continue;
                      //if(!lib.translate[skills[i]+'_info']) continue;
                      /*if(!controls.contains(skills[i])){
                          controls.push(skills[i]);
                      }*/
                      //console.log(info);
                      player.storage.shiduan3d8_buff2_skills = [];
                      if (info.enable && info.enable == 'phaseUse' && info.usable && info.usable == 1) {
                        result.targets[0].storage.shiduan3d8_buff2_skills.push(skills[i]);
                        //lib.skill[skills[i]].usable = 0;
                        result.targets[0].disableSkill("shiduan3d8", skills[i]);
                      }
                    }
                  } else {
                    result.targets[0].addTempSkill("shiduan3d8_buff1", {
                      player: "phaseEnd"
                    });
                    var skills = result.targets[0].get('s', false, false);
                    result.targets[0].storage.shiduan3d8_buff1_skills = [];
                    for (i = 0; i < skills.length; i++) {
                      var info = lib.skill[skills[i]];
                      if (!info) continue;
                      if (!lib.translate[skills[i]]) continue;
                      //if(!lib.translate[skills[i]+'_info']) continue;
                      /*if(!controls.contains(skills[i])){
                          controls.push(skills[i]);
                      }*/
                      player.storage.shiduan3d8_buff1_skills = [];
                      if (info.enable && info.enable == 'phaseUse' && info.usable && info.usable == 1) {
                        result.targets[0].storage.shiduan3d8_buff1_skills.push(skills[i]);
                        lib.skill[skills[i]].usable = 2;
                      }
                    }
                  }
                }
              },
              ai: {
                order: 9,
                result: {
                  player: function(player) {
                    /*var players = game.filterPlayer();
                    var has_jieduanji_friend = 0;
                    var has_jieduanji_enemy = 0;
                    var wu_jieduanji_friend = 0;
                    var wu_jieduanji_enemy = 0;
                    for(var i = 0;i<players.length;i++){
                        var target = players[i];
                        var skills=target.get('s',false,false);
                        var att = get.attitude(player,target);
                        var count = 0;
                        for(i=0;i<skills.length;i++){
                            var info=lib.skill[skills[i]];
                            if(!info) continue;
                            if(!lib.translate[skills[i]]) continue;
                            if(!lib.translate[skills[i]+'_info']) continue;
                            if(info.enable && info.enable == 'phaseUse' && info.usable && info.usable == 1){
                                count += 1;
                            }
                        }
                        if(count>0&&att>=0) has_jieduanji_friend = 1;
                        if(count>0&&att<=0) has_jieduanji_enemy = 1;
                        if(count==0&&att>=0) wu_jieduanji_friend = 1;
                        if(count==0&&att<=0) wu_jieduanji_enemy = 1;
                    }   
                    if(player.storage.shiduan3d8==true){
                        if(has_jieduanji_friend==1 || wu_jieduanji_enemy==1) return 1;
                        return 0;
                    }
                    if(no_jieduanji_friend==1 || has_jieduanji_enemy==1) return 1;
                    return 0;*/
                    return 1;
                  },
                },
              },
            },

            shiduan3d8_buff1: {
              charlotte: true,
              mark: true,
              marktext: "断",
              intro: {
                content: "出杀次数-1，使用以“出牌阶段限一次”开始的技能次数上限+1",
              },
              init: function(player, skill) {
                if (!player.storage[skill]) player.storage[skill] = 0;
              },
              onremove: function(player) {
                var skills = player.storage.shiduan3d8_buff1_skills;
                for (i = 0; i < skills.length; i++) {
                  lib.skill[skills[i]].usable = 1;
                }
              },
              mod: {
                cardUsable: function(card, player, num) {
                  if (card.name == 'sha') return num - 1;
                },
              },
            },

            shiduan3d8_buff2: {
              charlotte: true,
              mark: true,
              marktext: "断",
              intro: {
                content: "出杀次数+1，使用以“出牌阶段限一次”开始的技能次数上限-1",
              },
              init: function(player, skill) {
                if (!player.storage[skill]) player.storage[skill] = 0;
              },
              onremove: function(player) {
                var skills = player.storage.shiduan3d8_buff2_skills;
                for (i = 0; i < skills.length; i++) {
                  player.enableSkill("shiduan3d8", skills[i]);
                }
              },
              mod: {
                cardUsable: function(card, player, num) {
                  if (card.name == 'sha') return num + 1;
                },
              },
            },

            bingjian3d8: {
              group: ["bingjian3d8_one_sha", "bingjian3d8_one_shan", "bingjian3d8_one_alter", "bingjian3d8_two_sha", "bingjian3d8_two_shan", "bingjian3d8_two_alter"],
              trigger: {
                player: ["useCard", "respond"],
              },
              frequent: true,
              filter: function(event, player) {
                if (!event.skill) return false;
                if (event.skill != 'bingjian3d8_two_sha' && event.skill != 'bingjian3d8_two_shan') return false;
                var cards = event.cards;
                return cards.length == 2;
              },
              content: function() {
                'step 0'
                player.moveCard();
                'step 1'
                if (!result.bool) player.draw();
              },
              ai: {
                expose: 0.3,
                threaten: 1.2,
              },
            },

            bingjian3d8_one_sha: {
              enable: ["chooseToRespond", "chooseToUse"],
              filterCard: true,
              viewAs: {
                name: "sha",
              },
              audio: "qigong",
              position: 'he',
              filter: function(event, player) {
                return (player.countCards("h") == 2 || player.hp == 2) && !player.hasSkill("bingjian3d8_one_empty");
              },
              prompt: "将一张牌当作杀使用或打出",
              check: function(card) {
                return 6 - get.value(card)
              },
              ai: {
                yingbian: function(card, player, targets, viewer) {
                  if (get.attitude(viewer, player) <= 0) return 0;
                  var base = 0,
                    hit = false;
                  if (get.cardtag(card, 'yingbian_hit')) {
                    hit = true;
                    if (targets.filter(function(target) {
                        return target.hasShan() && get.attitude(viewer, target) < 0 && get.damageEffect(target, player, viewer, get.nature(card)) > 0;
                      })) base += 5;
                  }
                  if (get.cardtag(card, 'yingbian_all')) {
                    if (game.hasPlayer(function(current) {
                        return !targets.contains(current) && lib.filter.targetEnabled2(card, player, current) && get.effect(current, card, player, player) > 0;
                      })) base += 5;
                  }
                  if (get.cardtag(card, 'yingbian_damage')) {
                    if (targets.filter(function(target) {
                        return get.attitude(player, target) < 0 && (hit || !target.mayHaveShan() || player.hasSkillTag('directHit_ai', true, {
                          target: target,
                          card: card,
                        }, true)) && !target.hasSkillTag('filterDamage', null, {
                          player: player,
                          card: card,
                          jiu: true,
                        })
                      })) base += 5;
                  }
                  return base;
                },
                canLink: function(player, target, card) {
                  if (!target.isLinked() && !player.hasSkill('wutiesuolian_skill')) return false;
                  if (target.mayHaveShan() && !player.hasSkillTag('directHit_ai', true, {
                      target: target,
                      card: card,
                    }, true)) return false;
                  if (player.hasSkill('jueqing') || player.hasSkill('gangzhi') || target.hasSkill('gangzhi')) return false;
                  return true;
                },
                basic: {
                  useful: [5, 3, 1],
                  value: [5, 3, 1],
                },
                order: function(item, player) {
                  if (player.hasSkillTag('presha', true, null, true)) return 10;
                  if (lib.linked.contains(get.nature(item))) {
                    if (game.hasPlayer(function(current) {
                        return current != player && current.isLinked() && player.canUse(item, current, null, true) && get.effect(current, item, player, player) > 0 && lib.card.sha.ai.canLink(player, current, item);
                      }) && game.countPlayer(function(current) {
                        return current.isLinked() && get.damageEffect(current, player, player, get.nature(item)) > 0;
                      }) > 1) return 3.1;
                    return 3;
                  }
                  return 3.05;
                },
                result: {
                  target: function(player, target, card, isLink) {
                    var eff = function() {
                      if (!isLink && player.hasSkill('jiu')) {
                        if (!target.hasSkillTag('filterDamage', null, {
                            player: player,
                            card: card,
                            jiu: true,
                          })) {
                          if (get.attitude(player, target) > 0) {
                            return -7;
                          } else {
                            return -4;
                          }
                        }
                        return -0.5;
                      }
                      return -1.5;
                    }();
                    if (!isLink && target.mayHaveShan() && !player.hasSkillTag('directHit_ai', true, {
                        target: target,
                        card: card,
                      }, true)) return eff / 1.2;
                    return eff;
                  },
                },
                tag: {
                  respond: 1,
                  respondShan: 1,
                  damage: function(card) {
                    if (card.nature == 'poison') return;
                    return 1;
                  },
                  natureDamage: function(card) {
                    if (card.nature) return 1;
                  },
                  fireDamage: function(card, nature) {
                    if (card.nature == 'fire') return 1;
                  },
                  thunderDamage: function(card, nature) {
                    if (card.nature == 'thunder') return 1;
                  },
                  poisonDamage: function(card, nature) {
                    if (card.nature == 'poison') return 1;
                  },
                },
              },
            },

            bingjian3d8_one_shan: {
              enable: ["chooseToRespond", "chooseToUse"],
              position: 'he',
              filterCard: true,
              viewAs: {
                name: "shan",
              },
              audio: "qigong",
              filter: function(event, player) {
                return (player.countCards("h") == 2 || player.hp == 2) && !player.hasSkill("bingjian3d8_one_empty");
              },
              prompt: "将一张牌当作闪使用或打出",
              check: function(card) {
                return 6 - get.value(card)
              },
              ai: {
                order: 3,
                basic: {
                  useful: [7, 5.1, 2],
                  value: [7, 5.1, 2],
                },
                result: {
                  player: 1,
                },
              },
            },

            bingjian3d8_one_alter: {
              trigger: {
                player: ["useCard", "respond"],
              },
              forced: true,
              filter: function(event, player) {
                if (!event.skill) return false;
                if (event.skill != 'bingjian3d8_one_sha' && event.skill != 'bingjian3d8_one_shan') return false;
                return true;
              },
              content: function() {
                player.addTempSkill("bingjian3d8_one_empty", "phaseAfter");
              },
            },

            bingjian3d8_one_empty: {},

            bingjian3d8_two_sha: {
              enable: ["chooseToRespond", "chooseToUse"],
              filterCard: true,
              viewAs: {
                name: "sha",
              },
              audio: "qigong",
              position: 'he',
              selectCard: 2,
              filter: function(event, player) {
                return (player.countCards("h") == 2 || player.hp == 2) && !player.hasSkill("bingjian3d8_two_empty");
              },
              prompt: "将两张牌当作杀使用或打出",
              check: function(card) {
                return 6 - get.value(card)
              },
              ai: {
                yingbian: function(card, player, targets, viewer) {
                  if (get.attitude(viewer, player) <= 0) return 0;
                  var base = 0,
                    hit = false;
                  if (get.cardtag(card, 'yingbian_hit')) {
                    hit = true;
                    if (targets.filter(function(target) {
                        return target.hasShan() && get.attitude(viewer, target) < 0 && get.damageEffect(target, player, viewer, get.nature(card)) > 0;
                      })) base += 5;
                  }
                  if (get.cardtag(card, 'yingbian_all')) {
                    if (game.hasPlayer(function(current) {
                        return !targets.contains(current) && lib.filter.targetEnabled2(card, player, current) && get.effect(current, card, player, player) > 0;
                      })) base += 5;
                  }
                  if (get.cardtag(card, 'yingbian_damage')) {
                    if (targets.filter(function(target) {
                        return get.attitude(player, target) < 0 && (hit || !target.mayHaveShan() || player.hasSkillTag('directHit_ai', true, {
                          target: target,
                          card: card,
                        }, true)) && !target.hasSkillTag('filterDamage', null, {
                          player: player,
                          card: card,
                          jiu: true,
                        })
                      })) base += 5;
                  }
                  return base;
                },
                canLink: function(player, target, card) {
                  if (!target.isLinked() && !player.hasSkill('wutiesuolian_skill')) return false;
                  if (target.mayHaveShan() && !player.hasSkillTag('directHit_ai', true, {
                      target: target,
                      card: card,
                    }, true)) return false;
                  if (player.hasSkill('jueqing') || player.hasSkill('gangzhi') || target.hasSkill('gangzhi')) return false;
                  return true;
                },
                basic: {
                  useful: [5, 3, 1],
                  value: [5, 3, 1],
                },
                order: function(item, player) {
                  if (player.hasSkillTag('presha', true, null, true)) return 10.1;
                  if (lib.linked.contains(get.nature(item))) {
                    if (game.hasPlayer(function(current) {
                        return current != player && current.isLinked() && player.canUse(item, current, null, true) && get.effect(current, item, player, player) > 0 && lib.card.sha.ai.canLink(player, current, item);
                      }) && game.countPlayer(function(current) {
                        return current.isLinked() && get.damageEffect(current, player, player, get.nature(item)) > 0;
                      }) > 1) return 3.2;
                    return 3.1;
                  }
                  return 3.06;
                },
                result: {
                  target: function(player, target, card, isLink) {
                    var eff = function() {
                      if (!isLink && player.hasSkill('jiu')) {
                        if (!target.hasSkillTag('filterDamage', null, {
                            player: player,
                            card: card,
                            jiu: true,
                          })) {
                          if (get.attitude(player, target) > 0) {
                            return -7;
                          } else {
                            return -4;
                          }
                        }
                        return -0.5;
                      }
                      return -1.5;
                    }();
                    if (!isLink && target.mayHaveShan() && !player.hasSkillTag('directHit_ai', true, {
                        target: target,
                        card: card,
                      }, true)) return eff / 1.2;
                    return eff;
                  },
                },
                tag: {
                  respond: 1,
                  respondShan: 1,
                  damage: function(card) {
                    if (card.nature == 'poison') return;
                    return 1;
                  },
                  natureDamage: function(card) {
                    if (card.nature) return 1;
                  },
                  fireDamage: function(card, nature) {
                    if (card.nature == 'fire') return 1;
                  },
                  thunderDamage: function(card, nature) {
                    if (card.nature == 'thunder') return 1;
                  },
                  poisonDamage: function(card, nature) {
                    if (card.nature == 'poison') return 1;
                  },
                },
              },
            },

            bingjian3d8_two_shan: {
              enable: ["chooseToRespond", "chooseToUse"],
              position: 'he',
              filterCard: true,
              selectCard: 2,
              viewAs: {
                name: "shan",
              },
              audio: "qigong",
              filter: function(event, player) {
                return (player.countCards("h") == 2 || player.hp == 2) && !player.hasSkill("bingjian3d8_two_empty");
              },
              prompt: "将一张牌当作闪使用或打出",
              check: function(card) {
                return 6 - get.value(card)
              },
              ai: {
                order: 3.1,
                basic: {
                  useful: [7, 5.1, 2],
                  value: [7, 5.1, 2],
                },
                result: {
                  player: 1,
                },
              },
            },

            bingjian3d8_two_alter: {
              trigger: {
                player: ["useCard", "respond"],
              },
              forced: true,
              filter: function(event, player) {
                if (!event.skill) return false;
                if (event.skill != 'bingjian3d8_two_sha' && event.skill != 'bingjian3d8_two_shan') return false;
                return true;
              },
              content: function() {
                player.addTempSkill("bingjian3d8_two_empty", "phaseAfter");
              },
            },

            bingjian3d8_two_empty: {},

            shanquan3d8: {
              enable: "phaseUse",
              audio: "jlsg_zhuanshan",
              usable: 1,
              filter: function(event, player) {
                var players = game.filterPlayer();
                var flag = 0;
                for (var i = 0; i < players.length; i++) {
                  if (player == players[i]) continue;
                  var att = get.attitude(player, players[i]);
                  if (players[i].countCards("e") == 0) return true;
                  var cards = players[i].getCards("e");
                  for (var j = 0; j < cards.length; j++) {
                    var sub = get.subtype(cards[j]);
                    if (!player.getEquip(sub)) return true;
                  }
                }
                return false;
              },
              content: function() {
                'step 0'
                player.chooseControl().set('choiceList', [
                  '将场上的一张装备牌移动到你的装备区，然后弃置等同于你装备区里牌数的牌',
                  '对一名装备区里没有牌的角色造成1点伤害',
                ]).set('ai', function() {
                  var gain0 = 0;
                  var gain1 = 0;
                  var players = game.filterPlayer();
                  var flag = 0;
                  var cards = player.getCards("h");
                  var count = 0;
                  for (var i = 0; i < cards.length; i++) {
                    var card = cards[i];
                    if (game.hasPlayer(function(current) {
                        return lib.filter.targetEnabled2(card, player, current) && get.effect(current, card, player, player) > 0
                      })) continue;
                    if (get.value(card) >= 8) count += 1;
                  }
                  if (count >= player.getHandcardLimit() + 2 && player.hasSkill("xiongyi3d8")) count = 1;
                  else count = 0;
                  for (var i = 0; i < players.length; i++) {
                    if (player == players[i]) continue;
                    var att = get.attitude(player, players[i]);
                    if (players[i].countCards("e") == 0) {
                      if (get.damageEffect(players[i], player, player) > 0) {
                        if (players[i].hp == 1) gain1 = Math.max(gain1, 11);
                        else if (players[i].hp == 2) gain1 = Math.max(gain1, 8);
                        else if (players[i].hp == 3) gain1 = Math.max(gain1, 5);
                        else gain1 = Math.max(gain1, 2);
                      } else if (get.damageEffect(players[i], player, player) == 0) gain1 = Math.max(gain1, 1);
                      else if (count == 1) gain1 = Math.max(gain1, 0.5);
                    } else {
                      var cards = players[i].getCards("e");
                      for (var j = 0; j < cards.length; j++) {
                        var sub = get.subtype(cards[j]);
                        if (!player.getEquip(sub) && cards[j].name == 'baiyin' && att > 0 && players[i].isDamaged()) gain0 = Math.max(gain0, 8);
                        if (!player.getEquip(sub) && att < 0) {
                          if (get.value(cards[j]) >= 8 && player.countCards("e") < 3) gain0 = Math.max(gain0, 10 - player.countCards("e"));
                          else if (get.value(cards[j]) >= 6 && player.countCards("e") < 2) gain0 = Math.max(gain0, 6 - player.countCards("e"));
                          else if (player.countCards("e") < 2) gain0 = Math.max(gain0, 4 - player.countCards("e"));
                        }
                      }
                    }
                  }
                  if (gain0 > gain1) return 0;
                  else if (gain0 < gain1) return 1;
                  if (Math.random() > 0.5) return 0;
                  return 1;
                });
                'step 1'
                if (result.index == 1) event.goto(5);
                else if (result.index != 0) event.finish();
                else {
                  player.chooseTarget('请选择获得装备的角色', function(card, player, target) {
                    return target.countCards("e") > 0;
                  }).ai = function(target) {
                    var att = get.attitude(player, target);
                    var cards = target.getCards("e");
                    var val = 0;
                    var baiyin = 0;
                    for (var i = 0; i < cards.length; i++) {
                      val = Math.max(val, get.value(cards[i]));
                      if (cards[i].name == 'baiyin') baiyin = 1;
                    }
                    if (att > 0) {
                      if (baiyin == 1 && target.isDamaged()) return 7;
                      return 0.1;
                    }
                    if (att == 0) return 1;
                    return val;
                  };
                }

                'step 2'
                if (result.bool) {
                  player.logSkill("shanquan3d8", result.targets[0]);
                  var target = result.targets[0];
                  player.chooseCardButton('获得' + get.translation(target) + '装备区的一张牌', target.getCards('e'), 1, false)
                    .set('filterButton', function(button) {
                      var sub = get.subtype(button.link);
                      return !player.getEquip(sub);
                    }).set('ai', function(button) {
                      var sub = get.subtype(button.link);
                      return get.equipValue(button.link);
                    });
                }
                'step 3'
                if (result.bool) {
                  var eq = result.links[0];
                  player.equip(eq);
                }
                'step 4'
                player.chooseToDiscard(player.countCards("e"), 'he', true);
                event.finish();
                'step 5'
                player.chooseTarget('请选择造成伤害的角色', function(card, player, target) {
                  return target.countCards("e") == 0;
                }).ai = function(target) {
                  var cards = player.getCards("h");
                  var count = 0;
                  for (var i = 0; i < cards.length; i++) {
                    var card = cards[i];
                    if (game.hasPlayer(function(current) {
                        return lib.filter.targetEnabled2(card, player, current) && get.effect(current, card, player, player) > 0
                      })) continue;
                    if (get.value(card) >= 8) count += 1;
                  }
                  if (count >= player.getHandcardLimit() + 2 && player.hasSkill("xiongyi3d8")) count = 1;
                  else count = 0;
                  if (count == 0) return get.damageEffect(target, player, player) + 1;
                  else return get.damageEffect(target, player, player) + 10;
                };
                'step 6'
                if (result.bool) {
                  player.logSkill("shanquan3d8", result.targets[0]);
                  result.targets[0].damage();
                }
              },
              ai: {
                order: 9,
                result: {
                  player: function(player) {
                    var players = game.filterPlayer();
                    var flag = 0;
                    var cards = player.getCards("h");
                    var count = 0;
                    for (var i = 0; i < cards.length; i++) {
                      var card = cards[i];
                      if (game.hasPlayer(function(current) {
                          return lib.filter.targetEnabled2(card, player, current) && get.effect(current, card, player, player) > 0
                        })) continue;
                      if (get.value(card) >= 8) count += 1;
                    }
                    if (count >= player.getHandcardLimit() + 2 && player.hasSkill("xiongyi3d8")) count = 1;
                    else count = 0;
                    for (var i = 0; i < players.length; i++) {
                      if (player == players[i]) continue;
                      var att = get.attitude(player, players[i]);
                      if (players[i].countCards("e") == 0) {
                        if (get.damageEffect(players[i], player, player) >= 0) flag = 1;
                        else if (players[i].hp >= 3 && count == 1) flag = 1;
                      } else {
                        var cards = players[i].getCards("e");
                        for (var j = 0; j < cards.length; j++) {
                          var sub = get.subtype(cards[j]);
                          if (!player.getEquip(sub) && att < 0 && player.countCards("e") < 1) flag = 1;
                          else if (!player.getEquip(sub) && att < 0 && get.value(cards[j]) >= 8 && player.countCards("e") < 3) flag = 1;
                          else if (!player.getEquip(sub) && att < 0 && get.value(cards[j]) >= 6 && player.countCards("e") < 2) flag = 1;
                        }
                      }
                    }
                    if (flag == 1) return 1;
                    return 0;
                  },
                },
              },
            },

            xiongyi3d8: {
              trigger: {
                source: "dieAfter",
              },
              forced: true,
              audio: "jlsg_zhuanshan",
              filter: function(event, player) {
                return player.getHandcardLimit() > 0;
              },
              init: function(player) {
                player.storage.xiongyi3d8 = 0;
              },
              content: function() {
                player.storage.xiongyi3d8++;
              },
              group: "xiongyi3d8_discard",
              subSkill: {
                discard: {
                  trigger: {
                    player: "phaseDiscardBefore",
                  },
                  audio: "jlsg_zhuanshan",
                  forced: true,
                  filter: function(event, player) {　　　　　　　　　
                    return player.getHistory('sourceDamage').length;
                  },
                  content: function() {
                    trigger.cancel();
                  },
                },
              },
              mod: {
                maxHandcard: function(player, num) {
                  return num - player.storage.xiongyi3d8;
                },
              },
              mark: true,
              marktext: "溢",
              intro: {
                content: "已杀死#名角色",
              },
            },

            dujuan3d8: {
              audio: "jlsg_lijian",
              enable: 'phaseUse',
              filter: function(event, player) {
                return player.getHandcardLimit() > 0;
              },
              filterTarget: function(card, player, target) {
                return player != target;
              },
              init: function(player) {
                player.storage.dujuan3d8 = 0;
              },
              usable: 20,
              content: function() {
                'step 0'
                player.storage.dujuan3d8++;
                'step 1'　　　　　　　　　　
                target.chooseToDiscard("妒娟：弃置牌至" + get.cnNumber(target.getHandcardLimit()) + "张", target.countCards("he") - target.getHandcardLimit(), 'he', true);
              },
              ai: {
                order: function(player) {
                  return 9;
                },
                result: {
                  player: function(player, target) {
                    var count = player.getHandcardLimit() - player.countCards('he');
                    if (count <= 0) count = 1;
                    else count = 0;
                    if (target.countCards('he') > target.getHandcardLimit() && get.attitude(player, target) < 0) {
                      return target.countCards('he') - target.getHandcardLimit() - count;
                    }
                    return 0;
                  },
                },
              },
              mod: {
                maxHandcard: function(player, num) {
                  return num - player.storage.dujuan3d8;
                }
              },
              group: ['dujuan3d82']
            },

            dujuan3d82: {
              trigger: {
                player: 'phaseAfter'
              },
              silent: true,
              content: function() {
                player.storage.dujuan3d8 = 0;
              }
            },

            tuchou3d8: {
              audio: "jlsg_manwu",
              trigger: {
                global: "recoverBegin",
              },
              forced: true,
              filter: function(event, player) {
                return event.player != player && event.player.inRange(player) && !player.isMaxHandcard() && !player.isMaxHp();
              },
              content: function() {
                player.recover();
              },
            },

            humou3d8: {
              group: ["humou3d8_players"],
              init: function(player) {
                player.storage.humou3d8_array = ["0", "1", "2"];
                player.storage.humou3d8_players = [];
              },
              audio: "huaiyi",
              zhuanhuanji: true,
              mark: true,
              intro: {
                content: function(storage, player, skill) {
                  var str = "弃置一张黑色牌，";
                  if (player.storage.humou3d8_array[0] == "0") return str + '令一名手牌不少于你的角色摸一张牌';
                  else if (player.storage.humou3d8_array[0] == "1") return str + '观看一名手牌多于你的角色的手牌并可以使用其中一张';
                  else if (player.storage.humou3d8_array[0] == "2") return str + '视为对所有成为过“狐谋”目标的其他角色使用一张【万箭齐发】';
                },
              },
              enable: "phaseUse",
              usable: 1,
              position: 'he',
              filter: function(event, player) {
                if (player.storage.humou3d8_array[0] == "0") return true;
                if (player.storage.humou3d8_array[0] == "1") {
                  var players = game.filterPlayer();
                  for (var i = 0; i < players.length; i++) {
                    if (players[i].countCards('h') > player.countCards('h')) return true;
                  }
                  return false;
                }
                if (player.storage.humou3d8_array[0] == "2") {
                  var players = [];
                  var game_players = game.filterPlayer();
                  for (var i = 0; i < game_players.length; i++) {
                    var c_player = game_players[i];
                    if (player.storage.humou3d8_players.contains(c_player)) players.push(c_player);
                  }
                  if (players.length > 0) return true;
                }
                return false;
              },
              check: function(card) {
                return 6 - get.value(card);
              },
              filterCard: function(card) {
                return get.color(card) == 'black';
              },
              content: function() {
                'step 0'
                if (player.storage.humou3d8_array[0] == "0") {
                  player.chooseTarget('请选择一名手牌不少于你的角色，令其摸一张牌', function(card, player, target) {
                    return target.countCards('h') >= player.countCards('h');
                  }).set('ai', function(target) {
                    if (get.attitude(player, target) > 0) return Math.max(1, 5 - target.countCards("h"));
                    return 0;
                  });
                } else if (player.storage.humou3d8_array[0] == "1") event.goto(2);
                else if (player.storage.humou3d8_array[0] == "2") event.goto(5);
                'step 1'
                if (result.bool) {
                  player.logSkill("humou3d8", result.targets);
                  if (result.targets[0] != player && !player.storage.humou3d8_players.contains(result.targets[0])) {
                    player.storage.humou3d8_players.push(result.targets[0]);
                  }
                  result.targets[0].draw();
                }
                event.goto(6);
                'step 2'
                player.chooseTarget('请选择一名手牌多于你的角色，观看其手牌并可以使用其中一张', function(card, player, target) {
                  return target.countCards('h') > player.countCards('h');
                }).set('ai', function(target) {
                  return (-get.attitude(player, target) + 0.1) * (target.countCards('h') + 1);
                });
                'step 3'
                if (result.bool) {
                  event.target = result.targets[0];
                  player.logSkill("humou3d8", result.targets);
                  if (result.targets[0] != player && !player.storage.humou3d8_players.contains(result.targets[0])) {
                    player.storage.humou3d8_players.push(result.targets[0]);
                  }
                  player.chooseButton(['选择一张牌使用之', result.targets[0].getCards('h')], false)
                    .set('filterButton', function(button) {
                      var card = button.link;
                      //if(get.type(card)=='basic') return false;
                      if (card.name == 'sha' && player.getCardUsable('sha') == 0) {
                        return false;
                      };
                      var players = game.filterPlayer();
                      for (var i = 0; i < players.length; i++) {
                        if (player.canUse(button.link, players[i])) return true;
                      }
                      return false;
                    })
                    .set('ai', function(button) {
                      return get.value(button.link);
                    });
                } else event.finish();
                'step 4'
                if (result.bool) {
                  game.log(player, "决定使用", event.target, "的", result.links[0]);
                  event.target.lose(result.links[0], ui.special);
                  player.chooseUseTarget(result.links[0], false, true);
                } else game.log(player, "没有使用", event.target, "的牌");
                event.goto(6);
                'step 5'
                var players = [];
                var game_players = game.filterPlayer();
                for (var i = 0; i < game_players.length; i++) {
                  var c_player = game_players[i];
                  if (player.storage.humou3d8_players.contains(c_player)) players.push(c_player);
                }
                if (players.length > 0) {
                  player.logSkill("humou3d8", players);
                  player.useCard({
                    name: 'wanjian',
                    isCard: true
                  }, players);
                }

                'step 6'
                var temp = player.storage.humou3d8_array.shift();
                player.storage.humou3d8_array.push(temp);
                player.syncStorage('humou3d8_array');
                player.markSkill('humou3d8_players');
                player.syncStorage('humou3d8_players');
              },
              ai: {
                order: 9,
                result: {
                  player: function(player, target) {
                    if (player.storage.humou3d8_array[0] == "0") return 1;
                    if (player.storage.humou3d8_array[0] == "1") {
                      var players = game.filterPlayer();
                      for (var i = 0; i < players.length; i++) {
                        if (players[i].countCards('h') > player.countCards('h') && get.attitude(player, players[i]) < 0) return 1;
                      }
                    }
                    if (player.storage.humou3d8_array[0] == "2") {
                      var players = [];
                      var game_players = game.filterPlayer();
                      for (var i = 0; i < game_players.length; i++) {
                        var c_player = game_players[i];
                        if (player.storage.humou3d8_players.contains(c_player)) players.push(c_player);
                      }
                      var lose = 0;
                      for (var i = 0; i < players.length; i++) {
                        if (players[i].hp < players[i].maxHp) {
                          if (get.attitude(player, players[i]) > 0) {
                            if (players[i].hp < 2) {
                              if (players[i].getEquip("bagua")) lose -= 0.5;
                              else if (!players[i].getEquip("tengjia")) lose -= 1;
                            }
                            if (players[i].getEquip("bagua")) lose -= 0.5;
                            else if (!players[i].getEquip("tengjia")) lose -= 1;
                          } else if (get.attitude(player, players[i]) < 0) {
                            if (players[i].hp < 2) {
                              if (players[i].getEquip("bagua")) lose += 0.5;
                              else if (!players[i].getEquip("tengjia")) lose += 1;
                            }
                            if (players[i].getEquip("bagua")) lose += 0.5;
                            else if (!players[i].getEquip("tengjia")) lose += 1;
                          }
                        } else {
                          if (get.attitude(player, players[i]) > 0) {
                            if (players[i].getEquip("bagua")) lose -= 0.5;
                            else if (!players[i].getEquip("tengjia")) lose -= 1;
                          } else if (get.attitude(player, players[i]) < 0) {
                            if (players[i].getEquip("bagua")) lose += 0.5;
                            else if (!players[i].getEquip("tengjia")) lose += 1;
                          }
                        }
                      }
                      if (lose > 0) return 1;
                    }
                    return 0;
                  },
                },
              },
            },

            humou3d8_players: {
              sub: true,
              mark: true,
              marktext: "谋",
              intro: {
                content: function(storage, player, skill) {
                  var players = player.storage.humou3d8_players;
                  if (players.length == 0) return "没有其他角色成为过“狐谋”的目标";
                  var str = "";
                  for (var i = 0; i < players.length; i++) {
                    str += get.translation(players[i]);
                    if (i < players.length - 1) str += "、"
                  }
                  return "成为过“狐谋”的目标的其他角色：" + str;
                },
              },
            },

            xuanshi3d8: {
              trigger: {
                player: "damageEnd",
              },
              audio: "rehuaiyi",
              filter: function(event, player) {
                return player.hasSkill("humou3d8");
              },
              check: function(event, player) {
                var check2 = 0;
                var check3 = 0;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i].countCards('h') > player.countCards('h') && get.attitude(player, players[i]) < 0) check2 = 1;
                }
                var players = [];
                var game_players = game.filterPlayer();
                for (var i = 0; i < game_players.length; i++) {
                  var c_player = game_players[i];
                  if (player.storage.humou3d8_players.contains(c_player)) players.push(c_player);
                }
                var lose = 0;
                for (var i = 0; i < players.length; i++) {
                  if (players[i].hp < players[i].maxHp) {
                    if (get.attitude(player, players[i]) > 0) {
                      if (players[i].hp < 2) {
                        if (players[i].getEquip("bagua")) lose -= 0.5;
                        else if (!players[i].getEquip("tengjia")) lose -= 1;
                      }
                      if (players[i].getEquip("bagua")) lose -= 0.5;
                      else if (!players[i].getEquip("tengjia")) lose -= 1;
                    } else if (get.attitude(player, players[i]) < 0) {
                      if (players[i].hp < 2) {
                        if (players[i].getEquip("bagua")) lose += 0.5;
                        else if (!players[i].getEquip("tengjia")) lose += 1;
                      }
                      if (players[i].getEquip("bagua")) lose += 0.5;
                      else if (!players[i].getEquip("tengjia")) lose += 1;
                    }
                  } else {
                    if (get.attitude(player, players[i]) > 0) {
                      if (players[i].getEquip("bagua")) lose -= 0.5;
                      else if (!players[i].getEquip("tengjia")) lose -= 1;
                    } else if (get.attitude(player, players[i]) < 0) {
                      if (players[i].getEquip("bagua")) lose += 0.5;
                      else if (!players[i].getEquip("tengjia")) lose += 1;
                    }
                  }
                }
                if (lose > 0) check3 = 1;

                // option 1
                if (player.storage.humou3d8_array[0] == "0" && check2 == 1) return true;
                if (player.storage.humou3d8_array[0] == "1" && check3 == 1) return true;
                if (player.storage.humou3d8_array[0] == "2" && check3 == 0) return true;

                if ((check3 == 0 || check2 == 0) && game.roundNumber > game_players.length) return true;

                if ((check3 == 1 && check2 == 1) && game.roundNumber > game_players.length) return true;

                return false;
              },
              content: function() {
                'step 0'
                player.chooseControl().set('choiceList', [
                  '转换“狐谋”',
                  '失去“旋势”并删除“狐谋”的一个状态',
                ]).set('ai', function() {
                  var check2 = 0;
                  var check3 = 0;
                  var players = game.filterPlayer();
                  for (var i = 0; i < players.length; i++) {
                    if (players[i].countCards('h') > player.countCards('h') && get.attitude(player, players[i]) < 0) check2 = 1;
                  }
                  var players = [];
                  var game_players = game.filterPlayer();
                  for (var i = 0; i < game_players.length; i++) {
                    var c_player = game_players[i];
                    if (player.storage.humou3d8_players.contains(c_player)) players.push(c_player);
                  }
                  var lose = 0;
                  for (var i = 0; i < players.length; i++) {
                    if (players[i].hp < players[i].maxHp) {
                      if (get.attitude(player, players[i]) > 0) {
                        if (players[i].hp < 2) {
                          if (players[i].getEquip("bagua")) lose -= 0.5;
                          else if (!players[i].getEquip("tengjia")) lose -= 1;
                        }
                        if (players[i].getEquip("bagua")) lose -= 0.5;
                        else if (!players[i].getEquip("tengjia")) lose -= 1;
                      } else if (get.attitude(player, players[i]) < 0) {
                        if (players[i].hp < 2) {
                          if (players[i].getEquip("bagua")) lose += 0.5;
                          else if (!players[i].getEquip("tengjia")) lose += 1;
                        }
                        if (players[i].getEquip("bagua")) lose += 0.5;
                        else if (!players[i].getEquip("tengjia")) lose += 1;
                      }
                    } else {
                      if (get.attitude(player, players[i]) > 0) {
                        if (players[i].getEquip("bagua")) lose -= 0.5;
                        else if (!players[i].getEquip("tengjia")) lose -= 1;
                      } else if (get.attitude(player, players[i]) < 0) {
                        if (players[i].getEquip("bagua")) lose += 0.5;
                        else if (!players[i].getEquip("tengjia")) lose += 1;
                      }
                    }
                  }
                  if (lose > 0) check3 = 1;

                  // option 1
                  if (player.storage.humou3d8_array[0] == "0" && check2 == 1) {
                    if (game.roundNumber <= game_players.length) return 0;
                    return 1;
                  }
                  if (player.storage.humou3d8_array[0] == "1" && check3 == 1) {
                    if (game.roundNumber <= game_players.length) return 0;
                    return 1;
                  }
                  if (player.storage.humou3d8_array[0] == "2" && check3 == 0) {
                    if (game.roundNumber <= game_players.length) return 0;
                    return 1;
                  }

                  if (check3 == 0 && game.roundNumber > game_players.length) return 1;
                  if (check2 == 0 && game.roundNumber > game_players.length) return 1;
                  if (check2 == 1 && check3 == 1 && game.roundNumber > game_players.length) return 1;

                  return 0;
                });
                'step 1'
                if (result.index == 1) {
                  //event.type='remove';
                  player.chooseControl().set('choiceList', [
                    '删除“狐谋”状态①：令一名手牌不少于你的角色摸一张牌',
                    '删除“狐谋”状态②：观看一名手牌多于你的角色的手牌并可以使用其中一张',
                    '删除“狐谋”状态③：视为对所有成为过“狐谋”目标的其他角色使用一张【万箭齐发】',
                  ]).set('ai', function() {
                    var check2 = 0;
                    var check3 = 0;
                    var players = game.filterPlayer();
                    for (var i = 0; i < players.length; i++) {
                      if (players[i].countCards('h') > player.countCards('h') && get.attitude(player, players[i]) < 0) check2 = 1;
                    }
                    var players = [];
                    var game_players = game.filterPlayer();
                    for (var i = 0; i < game_players.length; i++) {
                      var c_player = game_players[i];
                      if (player.storage.humou3d8_players.contains(c_player)) players.push(c_player);
                    }
                    var lose = 0;
                    for (var i = 0; i < players.length; i++) {
                      if (players[i].hp < players[i].maxHp) {
                        if (get.attitude(player, players[i]) > 0) {
                          if (players[i].hp < 2) {
                            if (players[i].getEquip("bagua")) lose -= 0.5;
                            else if (!players[i].getEquip("tengjia")) lose -= 1;
                          }
                          if (players[i].getEquip("bagua")) lose -= 0.5;
                          else if (!players[i].getEquip("tengjia")) lose -= 1;
                        } else if (get.attitude(player, players[i]) < 0) {
                          if (players[i].hp < 2) {
                            if (players[i].getEquip("bagua")) lose += 0.5;
                            else if (!players[i].getEquip("tengjia")) lose += 1;
                          }
                          if (players[i].getEquip("bagua")) lose += 0.5;
                          else if (!players[i].getEquip("tengjia")) lose += 1;
                        }
                      } else {
                        if (get.attitude(player, players[i]) > 0) {
                          if (players[i].getEquip("bagua")) lose -= 0.5;
                          else if (!players[i].getEquip("tengjia")) lose -= 1;
                        } else if (get.attitude(player, players[i]) < 0) {
                          if (players[i].getEquip("bagua")) lose += 0.5;
                          else if (!players[i].getEquip("tengjia")) lose += 1;
                        }
                      }
                    }
                    if (lose > 0) check3 = 1;

                    // option 1
                    if (player.storage.humou3d8_array[0] == "0" && check2 == 1) return 0;
                    if (player.storage.humou3d8_array[0] == "1" && check3 == 1) return 1;
                    if (player.storage.humou3d8_array[0] == "2" && check3 == 0) return 2;

                    if (check3 == 0) return 2;
                    if (check2 == 0) return 1;
                    if (check2 == 1 && check3 == 1) return 0;
                    return 2;
                  });
                } else {
                  game.log(player, "转换了“狐谋”的状态");
                  var temp = player.storage.humou3d8_array.shift();
                  player.storage.humou3d8_array.push(temp);
                  player.syncStorage('humou3d8_array');
                  event.finish();
                }
                'step 2'
                if (result.index == 0) {
                  game.log(player, "删除了“狐谋”的状态一");
                  if (player.storage.humou3d8_array[0] == '2') player.storage.humou3d8_array = ["2", "1"];
                  else player.storage.humou3d8_array = ["1", "2"];
                  player.syncStorage('humou3d8_array');
                } else if (result.index == 1) {
                  game.log(player, "删除了“狐谋”的状态二");
                  if (player.storage.humou3d8_array[0] == '0') player.storage.humou3d8_array = ["0", "2"];
                  else player.storage.humou3d8_array = ["2", "0"];
                  player.syncStorage('humou3d8_array');
                } else if (result.index == 2) {
                  game.log(player, "删除了“狐谋”的状态三");
                  if (player.storage.humou3d8_array[0] == '1') player.storage.humou3d8_array = ["1", "0"];
                  else player.storage.humou3d8_array = ["0", "1"];
                  player.syncStorage('humou3d8_array');
                }
                player.removeSkill("xuanshi3d8");
              },
            },

            zhuanshe3d8: {
              audio: "shanzhuan",
              trigger: {
                global: "phaseUseBegin",
              },
              filter: function(event, player) {
                return event.player != player && player.countCards('h') > 0;
              },
              logTarget: "player",
              check: function(event, player) {
                var cards = player.getCards("h");
                var players = game.filterPlayer();
                for (var i = 0; i < cards.length; i++) {
                  var card = cards[i];
                  var flag = 0;
                  if (get.type(card) != 'basic' && get.type(card) != 'trick') flag = 1;
                  if (get.value(card) <= 6 && get.attitude(player, event.player) < 0) {
                    if (!game.hasPlayer(function(current) {
                        return event.player.canUse(card, current);
                      }) || event.player.getUseValue(card) < 0 && !get.tag(card, 'recover')) return true;
                  }
                  var can_use = 0;
                  var double = 0;
                  if (get.attitude(player, event.player) > 0) {
                    for (var i = 0; i < players.length; i++) {
                      var current = players[i];
                      if (event.player.canUse(card, current) > 0 && get.effect(current, card, event.player, player) > 0) can_use += 1;
                      if (lib.filter.targetEnabled2(card, event.player, current) && get.effect(current, card, event.player, player) > 0) double += 1;
                    }
                    if (can_use > 0 && double >= 2 && flag == 0) return true;
                    if (can_use > 0 && player.countCards("h") > 2) return true;
                  }
                }
                return false;
              },
              content: function() {
                "step 0"
                player.chooseCard('h', true, '交给' + get.translation(trigger.player) + '一张手牌').set('ai', function(card) {
                  var att = get.attitude(player, trigger.player);
                  if (att > 0) {
                    var can_use = 0;
                    var double = 0;
                    var flag = 0;
                    var players = game.filterPlayer();
                    if (get.type(card) != 'basic' && get.type(card) != 'trick') flag = 1;
                    for (var i = 0; i < players.length; i++) {
                      var current = players[i];
                      if (trigger.player.canUse(card, current) > 0 && get.effect(current, card, trigger.player, player) > 0) can_use += 1;
                      if (lib.filter.targetEnabled2(card, trigger.player, current) && get.effect(current, card, trigger.player, player) > 0) double += 1;
                    }
                    if (can_use > 0 && double >= 2 && flag == 0) return get.value(card) + 10;
                    if (can_use > 0) return get.value(card);
                    return 0.1;
                  }
                  if (att == 0) return 0.1;
                  if (!game.hasPlayer(function(current) {
                      return trigger.player.canUse(card, current);
                    }) || trigger.player.getUseValue(card) < 0 && !get.tag(card, 'recover')) return 7 - get.value(card);
                  return -1;
                });
                "step 1"
                trigger.player.gain(result.cards, player, 'give');
                player.storage.zhuanshe3d82 = result.cards[0].name;
                player.storage.zhuanshe3d82_player = trigger.player;
                player.addTempSkill("zhuanshe3d82");
                trigger.player.addTempSkill("zhuanshe3d83");
                player.addTempSkill("zhuanshe3d84");

              },
              ai: {
                threaten: 1.1,
                expose: 0.3,
                effect: {
                  player: function(card, player, target, current) {
                    if (!player.isPhaseUsing()) return;
                    if (get.type(card) != 'basic' && get.type(card) != 'trick') return;
                    var cards = player.getCards("h");
                    var useful = ai.get.useful(card);
                    var count = 0;
                    for (var i = 0; i < cards.length; i++) {
                      if (ai.get.useful(cards[i]) >= useful) count += 1;
                    }
                    if (count > player.getHandcardLimit()) return;
                    var players = game.filterPlayer();
                    for (var i = 0; i < players.length; i++) {
                      var target = players[i];
                      var can_use = 0;
                      var double = 0;
                      if (get.attitude(player, target) > 0 && player != target) {
                        for (var j = 0; j < players.length; j++) {
                          var current = players[j];
                          if (target.canUse(card, current) > 0 && get.effect(current, card, target, player) > 0) can_use += 1;
                          if (lib.filter.targetEnabled2(card, target, current) && get.effect(current, card, target, player) > 0) double += 1;
                        }
                        if (can_use > 0 && double >= 2) return 'zeroplayertarget';
                      }
                    }
                    return;
                  },
                },
              },
            },

            "zhuanshe3d82": {
              audio: "shanzhuan",
              trigger: {
                global: "useCard",
              },
              direct: true,
              charlotte: true,
              filter: function(event, player) {
                return event.player == player.storage.zhuanshe3d82_player && event.card.name == player.storage.zhuanshe3d82 && (get.type(event.card) == 'basic' || get.type(event.card) == 'trick');
              },
              content: function() {
                "step 0"
                player.chooseTarget(event.unchosen ? get.prompt('zhuanshe3d82') : null, '为' + get.translation(trigger.card) + '增加一个目标', function(card, player, target) {
                  var trigger = _status.event.getTrigger();
                  return !trigger.targets.contains(target) && lib.filter.targetEnabled2(trigger.card, trigger.player, target);
                }).set('ai', function(target) {
                  var trigger = _status.event.getTrigger();
                  return get.effect(target, trigger.card, trigger.player, _status.event.player);
                });
                "step 1"
                if (result.bool) {
                  if (!event.isMine()) game.delayx();
                  event.target = result.targets[0];
                } else {
                  event.finish();
                }
                "step 2"
                player.logSkill('zhuanshe3d82', event.target);
                trigger.targets.push(event.target);
              },
            },

            "zhuanshe3d83": {
              effect: {
                player: function(card, player, target) {
                  var players = game.filterPlayer();
                  for (var i = 0; i < players.length; i++) {
                    if (players[i] != player && players[i].hasSkill("weiqiu3d8") && get.attitude(players[i], player) < 0 &&
                      get.damageEffect(player, players[i], players[i]) > 0) return [1, 2];
                    if (players[i] != player && players[i].hasSkill("weiqiu3d8") && get.attitude(players[i], player) > 0) return [1, 2];
                  }
                  return;
                },
              },
            },

            "zhuanshe3d84": {
              audio: "shanzhuan",
              trigger: {
                global: "phaseEnd",
              },
              direct: true,
              filter: function(event, player) {
                var history = event.player.getHistory('useCard');
                for (var i = 0; i < history.length; i++) {
                  if (history[i].card.name == player.storage.zhuanshe3d82 && history[i].isPhaseUsing()) return false;
                }
                if (!event.player.hasSkill("zhuanshe3d83")) return false;
                return true;
              },
              content: function() {
                "step 0"
                player.chooseBool('是否对' + get.translation(trigger.player) + '造成一点伤害？').ai = function() {
                  return get.damageEffect(trigger.player, player, player) > 0
                };
                "step 1"
                if (result.bool) {
                  player.logSkill("zhuanshe3d84", trigger.player);
                  trigger.player.damage('nocard');
                }
              },
            },

            weiqiu3d8: {
              audio: "tuogu",
              trigger: {
                global: "recoverBefore",
              },
              //global: "weiqiu3d82",
              forced: true,
              filter: function(event, player) {
                return player.countCards('h') == 0;
              },
              content: function() {
                "step 0"
                trigger.cancel();
                "step 1"
                player.draw();
              },
            },

            weiqiu3d82: {
              effect: {
                target: function(card, player, target) {
                  if (!get.tag(card, 'recover')) return;
                  var players = game.filterPlayer();
                  for (var i = 0; i < players.length; i++) {
                    if (players[i] != player && players[i].hasSkill("weiqiu3d8") && players[i].countCards("h") == 0) return [0, -1];
                  }
                  return;
                },
              },
            },

            xianshi3d82: {
              trigger: {
                global: "roundStart"
              },
              filter: function(event, player) {
                return game.roundNumber > 1
              },
              forced: true,
              popup: false,
              content: function() {
                "step 0"
                if (player.storage.xianshi3d8 != true) player.storage.xianshi3d82 = true;
                else player.storage.xianshi3d82 = false;
                "step 1"
                delete player.storage.xianshi3d8;
                delete player.storage.xianshi3d8_gain;
                delete player.storage.xianshi3d8_discard;
              }
            },
            xianshi3d8: {
              group: "xianshi3d82",
              trigger: {
                global: "phaseBegin"
              },
              frequent: true,
              content: function() {
                "step 0"
                var num = 3;
                if (player.storage.xianshi3d82 == true) num = 6;
                event.cards = get.cards(num);
                var content = ["牌堆顶的" + get.cnNumber(event.cards.length) + "张牌", event.cards];
                game.log(player, "观看了牌堆顶的" + get.cnNumber(event.cards.length) + "张牌");
                player.chooseControl("ok").set("dialog", content);
                "step 1"
                if (player.storage.xianshi3d8_gain != true && player.storage.xianshi3d8_discard != true) {
                  player.chooseControl("cancel2").set("choiceList", [
                    "令" + get.translation(trigger.player) + "获得任意张相同颜色的牌",
                    "将其中任意张牌置入弃牌堆",
                  ]).set("ai", function() {
                    var player = _status.event.player;
                    var att = get.attitude(player, trigger.player);
                    if (att > 0) return 0;
                    return "cancel2";
                  });
                } else if (player.storage.xianshi3d8_gain == true && player.storage.xianshi3d8_discard != true) event.goto(5);
                else if (player.storage.xianshi3d8_gain != true && player.storage.xianshi3d8_discard == true) event.goto(3);
                else if (player.storage.xianshi3d8_gain == true && player.storage.xianshi3d8_discard == true) event.goto(7);
                "step 2"
                if (result.control == "cancel2") event.goto(7);
                else if (result.index == 0) event.goto(3);
                else event.goto(5);
                "step 3"
                player.chooseCardButton(event.cards, [1, Infinity], "请选择令" + get.translation(trigger.player) + "获得的牌").set("filterButton", function(button) {
                  if (ui.selected.buttons.length) return get.color(button.link) == get.color(ui.selected.buttons[0].link);
                  return true;
                }).set("ai", function(button) {
                  var player = _status.event.player;
                  if (get.attitude(player, trigger.player) <= 0) return 0;
                  return get.value(button.link);
                });
                "step 4"
                if (result.bool) {
                  event.cards.remove(result.links);
                  trigger.player.gain(result.links, "gain2");
                  player.storage.xianshi3d8 = true;
                  player.storage.xianshi3d8_gain = true;
                }
                event.goto(7);
                "step 5"
                player.chooseCardButton(event.cards, [1, Infinity], "请选择要置入弃牌堆的牌");
                "step 6"
                if (result.bool) {
                  trigger.player.$throw(result.links, 1000);
                  event.cards.remove(result.links);
                  game.log(player, "将" + get.translation(result.links) + "置入弃牌堆");
                  game.cardsDiscard(result.links);
                  player.storage.xianshi3d8_discard = true;
                }
                "step 7"
                for (var i = event.cards.length - 1; i >= 0; i--) {
                  event.cards[i].fix();
                  ui.cardPile.insertBefore(event.cards[i], ui.cardPile.childNodes[0]);
                }
                game.updateRoundNumber();
              }
            },
            zaowang3d8: {
              unique: true,
              enable: "phaseUse",
              skillAnimation: true,
              animationColor: "gray",
              limited: true,
              filter: function(event, player) {
                return true;
              },
              filterTarget: function(card, player, target) {
                return target != player && target != game.zhu;
              },
              content: function() {
                "step 0"
                player.awakenSkill("zaowang3d8");
                "step 1"
                target.gainMaxHp();
                target.recover();
                target.draw(3);
                target.showIdentity();
                "step 2"
                if (target.identity == "zhong") {
                  target.identity = "zhu";
                  target.showIdentity();
                  target.update();
                  game.zhu.identity = "zhong";
                  game.zhu.showIdentity();
                  game.zhu.update();
                  game.zhu = target;
                } else if (target.identity == "fan") {
                  target.addSkill("zaowang3d8_fan");
                }
              },
              ai: {
                order: 7,
                expose: 0.8,
                threaten: 1.5,
                result: {
                  target: function(player, target) {
                    return target.hp + Math.min(target.maxHp, 4);
                  },
                },
              },
            },
            zaowang3d8_fan: {
              trigger: {
                player: "dieAfter",
              },
              intro: {
                content: "已成为反贼之王，阵亡则主忠阵营直接胜利！",
              },
              charlotte: true,
              mark: true,
              marktext: "王",
              forced: true,
              popup: false,
              forceDie: true,
              firstDo: true,
              content: function() {
                "step 0"
                if (get.mode() != "identity") event.finish();
                "step 1"
                var bool = false;
                var id = game.me.identity;
                if (["zhu", "zhong", "mingzhong"].contains(id)) bool = true;
                else bool = false;
                game.showIdentity();
                game.over(bool);
              },
              ai: {
                threaten: 999
              }
            },

            shijiand3d8: {
              audio: "jlsg_bibu",
              init: function(player) {
                player.storage.shijiand3d8_array = ["0", "1", "2"];
              },
              zhuanhuanji: true,
              mark: true,
              direct: true,
              intro: {
                content: function(storage, player, skill) {
                  if (player.storage.shijiand3d8_array[0] == "0") return '当一张基本牌不因使用而置入弃牌堆时，你可以令一名非当前回合角色获得此牌，或令当前回合角色交给你一张牌。';
                  else if (player.storage.shijiand3d8_array[0] == "1") return '当一张装备牌不因使用而置入弃牌堆时，你可以令一名非当前回合角色获得此牌，或令当前回合角色交给你一张牌。';
                  else if (player.storage.shijiand3d8_array[0] == "2") return '当一张锦囊牌不因使用而置入弃牌堆时，你可以令一名非当前回合角色获得此牌，或令当前回合角色交给你一张牌。';
                },
              },
              trigger: {
                global: ["loseAfter", "cardsDiscardAfter", "respondAfter"],
              },
              filter: function(event, player) {
                if (event.name == 'lose') {
                  if (event.type != 'discard') return false;
                }
                if (event.name == 'cardsDiscard') {
                  var evt = event.getParent().relatedEvent;
                  if (!evt || evt.name != 'judge') return false;
                }
                if (event.name == 'respond') {
                  if (get.itemtype(event.cards) != 'cards' || get.position(event.cards[0], true) != 'o') return false;
                }
                var cards = event.cards;
                for (var i = 0; i < cards.length; i++) {
                  var card = cards[i];
                  if (get.position(card, true) == 'd') {
                    if (player.storage.shijiand3d8_array[0] == "0" && get.type(card) == 'basic') return true;
                    if (player.storage.shijiand3d8_array[0] == "1" && get.type(card) == 'equip') return true;
                    if (player.storage.shijiand3d8_array[0] == "2" && (get.type(card) == 'trick' || get.type(card) == 'delay')) return true;
                  }
                }
              },
              content: function() {
                'step 0'
                event.cards = [];
                var cards = trigger.cards;
                for (var i = 0; i < cards.length; i++) {
                  var card = cards[i];
                  if (get.position(card, true) == 'd' || event.position == ui.discardPile) {
                    if (player.storage.shijiand3d8_array[0] == "0" && get.type(card) == 'basic') event.cards.push(card);
                    if (player.storage.shijiand3d8_array[0] == "1" && get.type(card) == 'equip') event.cards.push(card);
                    if (player.storage.shijiand3d8_array[0] == "2" && (get.type(card) == 'trick' || get.type(card) == 'delay')) event.cards.push(card);
                  }
                }
                'step 1'
                var str = "不因使用进入弃牌堆的";
                if (player.storage.shijiand3d8_array[0] == "0") str += '基本牌';
                if (player.storage.shijiand3d8_array[0] == "1") str += '装备牌';
                if (player.storage.shijiand3d8_array[0] == "2") str += '锦囊牌';
                var content = [str, event.cards];
                //game.log(player, '观看了牌堆底的两张牌');
                player.chooseControl('ok').set('dialog', content);
                'step 2'
                player.chooseControl(function(event, player) {
                  var cards = event.cards;
                  var players = game.filterPlayer();
                  var friend = 0;
                  var enemy = 0;
                  for (var i = 0; i < players.length; i++) {
                    if (players[i] == _status.currentPhase) continue;
                    if (get.attitude(player, players[i]) >= 0) friend = 1;
                    if (get.attitude(player, players[i]) < 0) enemy = 1;
                  }
                  var val = 0;
                  var bad = 0;
                  var good = 0;
                  for (var i = 0; i < cards.length; i++) {
                    if (get.value(cards[i]) < 0) bad = 1;
                    if (get.value(cards[i]) > 0) val = 1;
                    if (get.value(cards[i]) >= 8) good = 1;
                  }
                  var att = get.attitude(player, _status.currentPhase);
                  if (att >= 0 || _status.currentPhase.countCards("he") == 0) {
                    if (friend == 1 && val == 1) return '选项一';
                    if (enemy == 1 && bad == 1) return '选项一';
                    return '选项三';
                  }
                  if (friend == 1 && good == 1) return '选项一';
                  return '选项二';
                }).set('prompt', '示俭').set('choiceList', ['令一名非' + get.translation(_status.currentPhase) + '的角色获得一张进入弃牌堆的相应牌', '令' + get.translation(_status.currentPhase) + '交给你一张牌', '取消发动“示俭”']);
                'step 3'
                if (result.control == '选项一') {
                  event.goto(4);
                }
                if (result.control == '选项二') {
                  event.goto(7);
                }
                if (result.control == '选项三') {
                  event.finish();
                }
                'step 4'
                player.chooseTarget('选择一名角色，令其获得一张“示俭”牌', function(card, player, target) {
                  return target != _status.currentPhase;
                }, true).set('ai', function(target) {
                  var cards = event.cards;
                  var val = 0;
                  var bad = 0;
                  var good = 0;
                  var players = game.filterPlayer();
                  var friend = 0;
                  var enemy = 0;
                  for (var i = 0; i < players.length; i++) {
                    if (players[i] == _status.currentPhase) continue;
                    if (get.attitude(player, players[i]) >= 0) friend = 1;
                    if (get.attitude(player, players[i]) < 0) enemy = 1;
                  }
                  for (var i = 0; i < cards.length; i++) {
                    if (get.value(cards[i]) < 0) bad = 1;
                    if (get.value(cards[i]) > 0) val = 1;
                    if (get.value(cards[i]) >= 8) good = 1;
                  }
                  if (bad == 1 && enemy == 1 && good == 0) return -get.attitude(player, target);
                  if (val == 1 && friend == 1) {
                    if (get.attitude(player, target) > 0) return 5 + Math.min(5 - target.countCards("h"), 1) + Math.min(5 - target.hp, 1);
                    if (get.attitude(player, target) == 0) return 0;
                    return -1;
                  }
                  return -get.attitude(player, target);
                });
                'step 5'
                if (result.bool) {
                  event.target = result.targets[0];
                  player.logSkill("shijiand3d8", event.target);
                  player.chooseButton(['选择一张牌令' + get.translation(event.target) + '获得', event.cards], true)
                    .set('filterButton', function(button) {
                      return true;
                    })
                    .set('ai', function(button) {
                      if (get.attitude(player, event.target) >= 0) return get.value(button.link);
                      return 20 - get.value(button.link);
                    });
                }
                'step 6'
                if (result.bool) {
                  event.target.gain(result.links, "gain2");
                  event.goto(9);
                }
                'step 7'
                player.logSkill("shijiand3d8", _status.currentPhase);
                if (_status.currentPhase.countCards("he") == 0) event.goto(9);
                _status.currentPhase.chooseCard('交给' + get.translation(player) + '一张牌', 1, 'he', true).ai = function(card) {
                  if (get.attitude(_status.currentPhase, player) <= 5) return 20 - get.value(card);
                  return get.value(card);
                }
                'step 8'
                if (result.bool) {
                  player.gain(result.cards[0], _status.currentPhase, 'giveAuto');
                }
                'step 9'
                var temp = player.storage.shijiand3d8_array.shift();
                player.storage.shijiand3d8_array.push(temp);
                player.syncStorage('shijiand3d8_array');
              },
              ai: {
                threaten: 1.8,
              },
            },

            zhengfeng3d8: {
              audio: "jlsg_kuangzheng",
              intro: {
                content: "cards",
              },
              enable: "phaseUse",
              usable: 1,
              init: function(player) {
                player.storage.zhengfeng3d8 = [];
              },
              filter: function(event, player) {
                return game.hasPlayer(function(current) {
                  return current.countCards("h") >= player.countCards("h") && current != player;
                });
              },
              filterTarget: function(card, player, target) {
                return player != target && target.countCards("h") >= player.countCards("h");
              },
              content: function() {
                "step 0"
                event.list1 = [];
                event.list2 = [];
                if (player.countCards("h") > 0) {
                  var chooseButton = player.chooseButton(3, ["你的手牌", player.getCards("h"), get.translation(target.name) + "的手牌", target.getCards("h")]);
                } else {
                  var chooseButton = player.chooseButton(3, [get.translation(target.name) + "的手牌", target.getCards("h")]);
                }
                chooseButton.set("target", target);
                chooseButton.set("ai", function(button) {
                  var player = _status.event.player;
                  var target = _status.event.target;
                  var ps = [];
                  var ts = [];
                  for (var i = 0; i < ui.selected.buttons.length; i++) {
                    var card = ui.selected.buttons[i].link;
                    if (target.getCards("h").contains(card)) ts.push(card);
                    else ps.push(card);
                  }
                  var card = button.link;
                  var owner = get.owner(card);
                  var val = get.value(card) || 1;
                  if (owner == target) return 2 * val;
                  return 8 - val;
                });
                chooseButton.set("filterButton", function(button) {
                  for (var i = 0; i < ui.selected.buttons.length; i++) {
                    if (get.type2(button.link) == get.type2(ui.selected.buttons[i].link)) return false;
                  };
                  return true;
                });
                "step 1"
                if (result.bool) {
                  if (player.storage.zhengfeng3d8.length > 0) {
                    player.gain(player.storage.zhengfeng3d8, "fromStorage", "gain2");
                    player.storage.zhengfeng3d8 = [];
                  }
                  var list = result.links;
                  for (var i = 0; i < list.length; i++) {
                    if (get.owner(list[i]) == player) {
                      event.list1.push(list[i]);
                    } else {
                      event.list2.push(list[i]);
                    };
                  };
                  if (event.list1.length && event.list2.length) {
                    player.storage.zhengfeng3d8 = player.storage.zhengfeng3d8.concat(event.list2);
                    target.lose(event.list2, ui.special, "toStorage");
                    player.storage.zhengfeng3d8 = player.storage.zhengfeng3d8.concat(event.list1);
                    player.lose(event.list1, ui.special, "toStorage");
                    player.markSkill("zhengfeng3d8");
                    player.syncStorage("zhengfeng3d8");

                  } else if (event.list2.length) {
                    player.storage.zhengfeng3d8 = player.storage.zhengfeng3d8.concat(event.list2);
                    target.lose(event.list2, ui.special, "toStorage");
                    player.markSkill("zhengfeng3d8");
                    player.syncStorage("zhengfeng3d8");
                  } else {
                    player.storage.zhengfeng3d8 = player.storage.zhengfeng3d8.concat(event.list1);
                    player.lose(event.list1, ui.special, "toStorage");
                    player.markSkill("zhengfeng3d8");
                    player.syncStorage("zhengfeng3d8");
                  }
                  for (var i = 0; i < list.length; i++) {
                    game.log(player, "将", get.owner(list[i]), "的", list[i], "置于武将牌上");
                  }
                }
              },
              ai: {
                order: 4,
                expose: 0.8,
                threaten: 3,
                result: {
                  player: function(player, target) {
                    return 1;
                  },
                  target: function(player, target) {
                    if (target.countCards("h") <= 2) return -2;
                    return -3;
                  },
                },
              },
            },

            tanli3d8: {
              audio: "jlsg_hemeng",
              trigger: {
                global: "useCardAfter",
              },
              filter: function(event, player) {
                var cards = player.getCards("h");
                if (cards.length == 0) return false;
                var flag = 0;
                for (var i = 0; i < cards.length; i++) {
                  var card = cards[i];
                  if (lib.filter.cardEnabled(card, player) && lib.filter.cardUsable(card, player) && game.hasPlayer(function(current) {
                      return player.canUse(card, current) && lib.filter.targetEnabled2(card, player, current);
                    })) flag = 1;
                }
                if (flag == 0) return false;
                return get.type(event.card) == 'equip' && event.player != player;
              },
              check: function(event, player) {
                var cards = player.getCards("h");
                if (cards.length == 0) return false;
                var flag = 0;
                for (var i = 0; i < cards.length; i++) {
                  var card = cards[i];
                  if (lib.filter.cardEnabled(card, player) && lib.filter.cardUsable(card, player) && game.hasPlayer(function(current) {
                      return player.canUse(card, current) && lib.filter.targetEnabled2(card, player, current);
                    }) && player.getUseValue(card) >= 0) flag = 1;
                }
                if (flag == 0) return false;
                var att = get.attitude(player, event.player);
                if (att <= 0) return true;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i] == event.player) continue;
                  if (get.attitude(player, players[i]) <= 0) continue;
                  if (get.subtype(event.card.cards[0]) == 'equip1' && (players[i].get('e', '1') == undefined) && event.player.countCards("h") < players[i].countCards("h")) return true;
                  if (get.subtype(event.card.cards[0]) == 'equip2' && (players[i].get('e', '2') == undefined) && event.player.hp > players[i].hp) return true;
                  if (get.subtype(event.card.cards[0]) == 'equip3' && (players[i].get('e', '3') == undefined) && event.player.hp > players[i].hp) return true;
                  if (get.subtype(event.card.cards[0]) == 'equip4' && (players[i].get('e', '4') == undefined) && event.player.countCards("h") < players[i].countCards("h")) return true;
                  if (get.subtype(event.card.cards[0]) == 'equip5' && (players[i].get('e', '5') == undefined) && event.player.countCards("h") < players[i].countCards("h")) return true;
                }
                return false;
              },
              content: function() {
                'step 0'
                console.log("tanli1");
                player.chooseCard({
                  filterCard: function(card) {
                    return lib.filter.cardEnabled(card, player) && lib.filter.cardUsable(card, player) && game.hasPlayer(function(current) {
                      return player.canUse(card, current) && lib.filter.targetEnabled2(card, player, current);
                    });
                  },
                  position: 'h',
                  selectCard: 1,
                  ai: function(card) {
                    return player.getUseValue(card) + 1;
                  },
                  prompt: '选择一张手牌使用'
                });
                'step 1'
                if (result.bool) {
                  player.chooseUseTarget(result.cards[0], true, false);
                } else event.finish();
                'step 2'
                console.log("tanli2");
                if (!trigger.player.isAlive()) event.finish();
                var flag = 0;
                var cards = trigger.player.getCards("e");
                for (var i = 0; i < cards.length; i++) {
                  if (cards[i] == trigger.card.cards[0]) flag = 1;
                }
                if (result.bool && trigger.player.isAlive() && flag == 1) {
                  player.chooseControl(function(event, player) {
                    if (get.attitude(player, trigger.player) > 0) return '选项二';
                    if (get.value(trigger.card) >= 8) return '选项二';
                    return '选项一';
                  }).set('prompt', '探骊').set('choiceList', ['摸一张牌，令' + get.translation(trigger.player) + '弃置' + get.translation(trigger.card), '令' + get.translation(trigger.player) + '摸一张牌，将' + get.translation(trigger.card) + '置入另一名角色的装备区']);
                } else event.finish();
                'step 3'
                console.log("tanli3");
                if (result.control == '选项二') {
                  trigger.player.draw();
                  player.chooseTarget('选择一名角色，令其装备' + get.translation(trigger.card), function(card, player, target) {
                    return target != trigger.player;
                  }, true).set('ai', function(target) {
                    if (get.attitude(player, target) <= 0) return -1;
                    if (get.subtype(trigger.card.cards[0]) == 'equip1' && (target.get('e', '1') == undefined)) return Math.max(2, target.countCards("h"));
                    if (get.subtype(trigger.card.cards[0]) == 'equip2' && (target.get('e', '2') == undefined)) return Math.max(2, 10 - target.hp);
                    if (get.subtype(trigger.card.cards[0]) == 'equip3' && (target.get('e', '3') == undefined)) return Math.max(2, 10 - target.hp);
                    if (get.subtype(trigger.card.cards[0]) == 'equip4' && (target.get('e', '4') == undefined)) return Math.max(2, target.countCards("h"));
                    if (get.subtype(trigger.card.cards[0]) == 'equip5' && (target.get('e', '5') == undefined)) return Math.max(2, target.countCards("h"));
                    if (get.subtype(trigger.card.cards[0]) == 'equip1' && (target.get('e', '1') != undefined)) return Math.max(1, 5 - get.value(target.get('e', '1')));
                    if (get.subtype(trigger.card.cards[0]) == 'equip2' && (target.get('e', '2') != undefined)) return Math.max(1, 5 - get.value(target.get('e', '2')));
                    if (get.subtype(trigger.card.cards[0]) == 'equip3' && (target.get('e', '3') != undefined)) return Math.max(1, 5 - get.value(target.get('e', '3')));
                    if (get.subtype(trigger.card.cards[0]) == 'equip4' && (target.get('e', '4') != undefined)) return Math.max(1, 5 - get.value(target.get('e', '4')));
                    if (get.subtype(trigger.card.cards[0]) == 'equip5' && (target.get('e', '5') != undefined)) return Math.max(1, 5 - get.value(target.get('e', '5')));
                    return 1;
                  });
                }
                if (result.control == '选项一') {
                  player.draw();
                  trigger.player.discard(trigger.card.cards[0]);
                  event.finish();
                }
                'step 4'
                console.log("tanli4");
                if (result.bool) {
                  result.targets[0].equip(trigger.card.cards[0]);
                }
              },
              ai: {
                expose: 0.2,
                threaten: 2.5,
                effect: {
                  player: function(card, player, target, current) {
                    if (!player.isPhaseUsing()) return;
                    if (player.countCards("h") <= player.getHandcardLimit()) return [1, -3]
                    return;
                  },
                },
              },

            },

            dengjing3d8: {
              audio: "jlsg_sujian",
              group: ["dengjing3d8_init", "dengjing3d8_equip"],
              trigger: {
                global: ["equipAfter", "addJudgeAfter", "loseAfter", "gainAfter", "loseAsyncAfter"],
              },
              mod: {
                cardDiscardable: function(card, player, event) {
                  if (get.position(card) == 'e' && get.subtype(card) == 'equip1' && player.storage.equip1_player != 0) return false;
                  if (get.position(card) == 'e' && get.subtype(card) == 'equip2' && player.storage.equip2_player != 0) return false;
                  if (get.position(card) == 'e' && get.subtype(card) == 'equip3' && player.storage.equip3_player != 0) return false;
                  if (get.position(card) == 'e' && get.subtype(card) == 'equip4' && player.storage.equip4_player != 0) return false;
                  if (get.position(card) == 'e' && get.subtype(card) == 'equip5' && player.storage.equip5_player != 0) return false;
                },
                canBeDiscarded: function(card, player, target, event) {
                  if (get.position(card) == 'e' && get.subtype(card) == 'equip1' && target.storage.equip1_player != 0) return false;
                  if (get.position(card) == 'e' && get.subtype(card) == 'equip2' && target.storage.equip2_player != 0) return false;
                  if (get.position(card) == 'e' && get.subtype(card) == 'equip3' && target.storage.equip3_player != 0) return false;
                  if (get.position(card) == 'e' && get.subtype(card) == 'equip4' && target.storage.equip4_player != 0) return false;
                  if (get.position(card) == 'e' && get.subtype(card) == 'equip5' && target.storage.equip5_player != 0) return false;
                },
                canBeGained: function(card, player, target, event) {
                  if (get.position(card) == 'e' && get.subtype(card) == 'equip1' && target.storage.equip1_player != 0) return false;
                  if (get.position(card) == 'e' && get.subtype(card) == 'equip2' && target.storage.equip2_player != 0) return false;
                  if (get.position(card) == 'e' && get.subtype(card) == 'equip3' && target.storage.equip3_player != 0) return false;
                  if (get.position(card) == 'e' && get.subtype(card) == 'equip4' && target.storage.equip4_player != 0) return false;
                  if (get.position(card) == 'e' && get.subtype(card) == 'equip5' && target.storage.equip5_player != 0) return false;
                },
              },
              filter: function(event, player) {
                if (event.player == player) return false;
                var max = 0;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i] == player) continue;
                  max = Math.max(players[i].countCards("he"), max);
                }
                var count = 0;
                var target = player;
                for (var i = 0; i < players.length; i++) {
                  if (players[i] == player) continue;
                  if (players[i].countCards("he") == max) {
                    count += 1;
                    target = players[i];
                  }
                }
                if (count != 1) {
                  if (player.storage.equip1_player != 0) return true;
                  if (player.storage.equip2_player != 0) return true;
                  if (player.storage.equip3_player != 0) return true;
                  if (player.storage.equip4_player != 0) return true;
                  if (player.storage.equip5_player != 0) return true;
                  return false;
                }
                if (player.get('e', '1') == undefined && target.get('e', '1') != undefined) return true;
                if (player.get('e', '2') == undefined && target.get('e', '2') != undefined) return true;
                if (player.get('e', '3') == undefined && target.get('e', '3') != undefined) return true;
                if (player.get('e', '4') == undefined && target.get('e', '4') != undefined) return true;
                if (player.get('e', '5') == undefined && target.get('e', '5') != undefined) return true;
                if (player.get('e', '1') != undefined && target.get('e', '1') == undefined && player.storage.equip1_player == target) return true;
                if (player.get('e', '2') != undefined && target.get('e', '2') == undefined && player.storage.equip2_player == target) return true;
                if (player.get('e', '3') != undefined && target.get('e', '3') == undefined && player.storage.equip3_player == target) return true;
                if (player.get('e', '4') != undefined && target.get('e', '4') == undefined && player.storage.equip4_player == target) return true;
                if (player.get('e', '5') != undefined && target.get('e', '5') == undefined && player.storage.equip5_player == target) return true;
                if (player.storage.equip1_player != 0 && player.storage.equip1_player != target) return true;
                if (player.storage.equip2_player != 0 && player.storage.equip2_player != target) return true;
                if (player.storage.equip3_player != 0 && player.storage.equip3_player != target) return true;
                if (player.storage.equip4_player != 0 && player.storage.equip4_player != target) return true;
                if (player.storage.equip5_player != 0 && player.storage.equip5_player != target) return true;
                return false;
              },
              forced: true,
              popup: false,
              content: function() {
                'step 0'
                var players = game.filterPlayer();
                var max = 0;
                for (var i = 0; i < players.length; i++) {
                  if (players[i] == player) continue;
                  max = Math.max(players[i].countCards("he"), max);
                }
                var count = 0;
                var target = player;
                for (var i = 0; i < players.length; i++) {
                  if (players[i] == player) continue;
                  if (players[i].countCards("he") == max) {
                    count += 1;
                    target = players[i];
                  }
                }
                if (count != 1) {
                  if (player.storage.equip1_player != 0) {
                    player.storage.equip1_player = 0;
                    player.storage.equip1_card = 0;
                    if (player.get('e', '1')) player.get('e', '1').delete();
                  }
                  if (player.storage.equip2_player != 0) {
                    player.storage.equip2_player = 0;
                    player.storage.equip2_card = 0;
                    if (player.get('e', '2')) player.get('e', '2').delete();
                  }
                  if (player.storage.equip3_player != 0) {
                    player.storage.equip3_player = 0;
                    player.storage.equip3_card = 0;
                    if (player.get('e', '3')) player.get('e', '3').delete();
                  }
                  if (player.storage.equip4_player != 0) {
                    player.storage.equip4_player = 0;
                    player.storage.equip4_card = 0;
                    if (player.get('e', '4')) player.get('e', '4').delete();
                  }
                  if (player.storage.equip5_player != 0) {
                    player.storage.equip5_player = 0;
                    player.storage.equip5_card = 0;
                    if (player.get('e', '5')) player.get('e', '5').delete();
                  }
                  event.finish();
                }
                var flag = 0;
                var flag1 = 1;
                var flag2 = 1;
                var flag3 = 1;
                if (player.get('e', '1') == undefined && target.get('e', '1') != undefined) flag = 1;
                if (player.get('e', '2') == undefined && target.get('e', '2') != undefined) flag = 1;
                if (player.get('e', '3') == undefined && target.get('e', '3') != undefined) flag = 1;
                if (player.get('e', '4') == undefined && target.get('e', '4') != undefined) flag = 1;
                if (player.get('e', '5') == undefined && target.get('e', '5') != undefined) flag = 1;
                if (player.get('e', '1') != undefined && target.get('e', '1') == undefined && player.storage.equip1_player == target) flag1 = 1;
                if (player.get('e', '2') != undefined && target.get('e', '2') == undefined && player.storage.equip2_player == target) flag1 = 1;
                if (player.get('e', '3') != undefined && target.get('e', '3') == undefined && player.storage.equip3_player == target) flag1 = 1;
                if (player.get('e', '4') != undefined && target.get('e', '4') == undefined && player.storage.equip4_player == target) flag1 = 1;
                if (player.get('e', '5') != undefined && target.get('e', '5') == undefined && player.storage.equip5_player == target) flag1 = 1;
                if (player.storage.equip1_player != 0 && player.storage.equip1_player != target) {
                  flag2 = 1;
                  if (target.get('e', '1') != undefined) flag3 = 1;
                }
                if (player.storage.equip2_player != 0 && player.storage.equip2_player != target) {
                  flag2 = 1;
                  if (target.get('e', '2') != undefined) flag3 = 1;
                }
                if (player.storage.equip3_player != 0 && player.storage.equip3_player != target) {
                  flag2 = 1;
                  if (target.get('e', '3') != undefined) flag3 = 1;
                }
                if (player.storage.equip4_player != 0 && player.storage.equip4_player != target) {
                  flag2 = 1;
                  if (target.get('e', '4') != undefined) flag3 = 1;
                }
                if (player.storage.equip5_player != 0 && player.storage.equip5_player != target) {
                  flag2 = 1;
                  if (target.get('e', '5') != undefined) flag3 = 1;
                }
                if (flag == 0 && flag1 == 0 && flag2 == 0) event.finish();
                if (flag == 1 || flag3 == 1) player.logSkill("dengjing3d8");
                if (player.get('e', '1') == undefined && target.get('e', '1') != undefined) {
                  var cd = target.get('e', '1');
                  var card = game.createCard(cd);
                  player.equip(card);
                  player.storage.equip1_player = target;
                  player.storage.equip1_card = card;
                }
                if (player.get('e', '2') == undefined && target.get('e', '2') != undefined) {
                  var cd = target.get('e', '2');
                  var card = game.createCard(cd);
                  player.equip(card);
                  player.storage.equip2_player = target;
                  player.storage.equip2_card = card;
                }
                if (player.get('e', '3') == undefined && target.get('e', '3') != undefined) {
                  var cd = target.get('e', '3');
                  var card = game.createCard(cd);
                  player.equip(card);
                  player.storage.equip3_player = target;
                  player.storage.equip3_card = card;
                }
                if (player.get('e', '4') == undefined && target.get('e', '4') != undefined) {
                  var cd = target.get('e', '4');
                  var card = game.createCard(cd);
                  player.equip(card);
                  player.storage.equip4_player = target;
                  player.storage.equip4_card = card;
                }
                if (player.get('e', '5') == undefined && target.get('e', '5') != undefined) {
                  var cd = target.get('e', '5');
                  var card = game.createCard(cd);
                  player.equip(card);
                  player.storage.equip5_player = target;
                  player.storage.equip5_card = card;
                }
                if (player.get('e', '1') != undefined && target.get('e', '1') == undefined) {
                  if (player.storage.equip1_player == target) {
                    player.storage.equip1_player = 0;
                    player.storage.equip1_card = 0;
                    if (player.get('e', '1')) player.get('e', '1').delete();
                  }
                }
                if (player.get('e', '2') != undefined && target.get('e', '2') == undefined) {
                  if (player.storage.equip2_player == target) {
                    player.storage.equip2_player = 0;
                    player.storage.equip2_card = 0;
                    if (player.get('e', '2')) player.get('e', '2').delete();
                  }
                }
                if (player.get('e', '3') != undefined && target.get('e', '3') == undefined) {
                  if (player.storage.equip3_player == target) {
                    player.storage.equip3_player = 0;
                    player.storage.equip3_card = 0;
                    if (player.get('e', '3')) player.get('e', '3').delete();
                  }
                }
                if (player.get('e', '4') != undefined && target.get('e', '4') == undefined) {
                  if (player.storage.equip4_player == target) {
                    player.storage.equip4_player = 0;
                    player.storage.equip4_card = 0;
                    if (player.get('e', '4')) player.get('e', '4').delete();
                  }
                }
                if (player.get('e', '5') != undefined && target.get('e', '5') == undefined) {
                  if (player.storage.equip5_player == target) {
                    player.storage.equip5_player = 0;
                    player.storage.equip5_card = 0;
                    if (player.get('e', '5')) player.get('e', '5').delete();
                  }
                }
                if (player.storage.equip1_player != target && player.storage.equip1_player != 0) {
                  player.storage.equip1_player = 0;
                  player.storage.equip1_card = 0;
                  if (player.get('e', '1')) player.get('e', '1').delete();
                  if (target.get('e', '1') != undefined) {
                    var cd = target.get('e', '1');
                    var card = game.createCard(cd);
                    player.equip(card);
                    player.storage.equip1_player = target;
                    player.storage.equip1_card = card;
                  }
                }
                if (player.storage.equip2_player != target && player.storage.equip2_player != 0) {
                  player.storage.equip2_player = 0;
                  player.storage.equip2_card = 0;
                  if (player.get('e', '2')) player.get('e', '2').delete();
                  if (target.get('e', '2') != undefined) {
                    var cd = target.get('e', '2');
                    var card = game.createCard(cd);
                    player.equip(card);
                    player.storage.equip2_player = target;
                    player.storage.equip2_card = card;
                  }
                }
                if (player.storage.equip3_player != target && player.storage.equip3_player != 0) {
                  player.storage.equip3_player = 0;
                  player.storage.equip3_card = 0;
                  if (player.get('e', '3')) player.get('e', '3').delete();
                  if (target.get('e', '3') != undefined) {
                    var cd = target.get('e', '3');
                    var card = game.createCard(cd);
                    player.equip(card);
                    player.storage.equip3_player = target;
                    player.storage.equip3_card = card;
                  }
                }
                if (player.storage.equip4_player != target && player.storage.equip4_player != 0) {
                  player.storage.equip4_player = 0;
                  player.storage.equip4_card = 0;
                  if (player.get('e', '4')) player.get('e', '4').delete();
                  if (target.get('e', '4') != undefined) {
                    var cd = target.get('e', '4');
                    var card = game.createCard(cd);
                    player.equip(card);
                    player.storage.equip4_player = target;
                    player.storage.equip4_card = card;
                  }
                }
                if (player.storage.equip5_player != target && player.storage.equip5_player != 0) {
                  player.storage.equip5_player = 0;
                  player.storage.equip5_card = 0;
                  if (player.get('e', '5')) player.get('e', '5').delete();
                  if (target.get('e', '5') != undefined) {
                    var cd = target.get('e', '5');
                    var card = game.createCard(cd);
                    player.equip(card);
                    player.storage.equip5_player = target;
                    player.storage.equip5_card = card;
                  }
                }
              },
              subSkill: {
                init: {
                  forced: true,
                  popup: false,
                  trigger: {
                    global: "gameStart",
                  },
                  content: function() {
                    player.storage.equip1_player = 0;
                    player.storage.equip1_card = 0;
                    player.storage.equip2_player = 0;
                    player.storage.equip2_card = 0;
                    player.storage.equip3_player = 0;
                    player.storage.equip3_card = 0;
                    player.storage.equip4_player = 0;
                    player.storage.equip4_card = 0;
                    player.storage.equip5_player = 0;
                    player.storage.equip5_card = 0;
                  },
                },
                equip: {
                  forced: true,
                  popup: false,
                  trigger: {
                    player: "equipAfter",
                  },
                  filter: function(event, player) {
                    var card = event.card;
                    if (get.subtype(card) == 'equip1' && card != player.storage.equip1_card && player.storage.equip1_player != 0) return true;
                    if (get.subtype(card) == 'equip2' && card != player.storage.equip2_card && player.storage.equip2_player != 0) return true;
                    if (get.subtype(card) == 'equip3' && card != player.storage.equip3_card && player.storage.equip3_player != 0) return true;
                    if (get.subtype(card) == 'equip4' && card != player.storage.equip4_card && player.storage.equip4_player != 0) return true;
                    if (get.subtype(card) == 'equip5' && card != player.storage.equip5_card && player.storage.equip5_player != 0) return true;
                  },
                  content: function() {
                    var card = trigger.card;
                    if (get.subtype(card) == 'equip1' && card != player.storage.equip1_card && player.storage.equip1_player != 0) {
                      if (player.storage.equip1_card) player.storage.equip1_card.delete();
                      player.storage.equip1_player = 0;
                      player.storage.equip1_card = 0;
                    }
                    if (get.subtype(card) == 'equip2' && card != player.storage.equip2_card && player.storage.equip2_player != 0) {
                      if (player.storage.equip2_card) player.storage.equip2_card.delete();
                      player.storage.equip2_player = 0;
                      player.storage.equip2_card = 0;
                    }
                    if (get.subtype(card) == 'equip3' && card != player.storage.equip3_card && player.storage.equip3_player != 0) {
                      if (player.storage.equip3_card) player.storage.equip3_card.delete();
                      player.storage.equip3_player = 0;
                      player.storage.equip3_card = 0;
                    }
                    if (get.subtype(card) == 'equip4' && card != player.storage.equip4_card && player.storage.equip4_player != 0) {
                      if (player.storage.equip4_card) player.storage.equip4_card.delete();
                      player.storage.equiq4_player = 0;
                      player.storage.equip4_card = 0;
                    }
                    if (get.subtype(card) == 'equip5' && card != player.storage.equip5_card && player.storage.equip5_player != 0) {
                      if (player.storage.equip5_card) player.storage.equip5_card.delete();
                      player.storage.equip5_player = 0;
                      player.storage.equip5_card = 0;
                    }
                  },
                },
              }
            },

            wenbing3d8: {
              audio: "gs_xuanlue",
              marktext: "镇",
              mark: true,
              intro: {
                name: "稳兵",
                content: "mark",
              },
              locked: false,
              group: ["wenbing3d8_init", "wenbing3d8_1", "wenbing3d8_2", "wenbing3d8_3"],
              subSkill: {
                "1": {
                  trigger: {
                    player: "phaseJieshuBegin",
                  },
                  direct: true,
                  popup: false,
                  content: function() {
                    "step 0"
                    player.chooseControl('调整', '不调整', function(event, player) {
                      if (player.countCards('h') <= player.countMark('wenbing3d8')) return '调整';
                      if (player.countCards('h') - player.countMark('wenbing3d8') >= 3) return '不调整';
                      return '调整';
                    }).set('prompt', '稳兵：是否将手牌调整到' + get.cnNumber(player.countMark('wenbing3d8')) + '张');
                    "step 1"
                    if (result.control) {
                      if (result.control == '不调整') event.finish();
                      else {
                        player.logSkill("wenbing3d8");
                        event.goto(2);
                      }
                    }
                    "step 2"
                    if (player.countCards('h') > player.countMark('wenbing3d8')) {
                      var num = player.countCards('h') - player.countMark('wenbing3d8');
                      player.chooseToDiscard(num, 'h', true)
                      player.addMark("wenbing3d8");
                      event.finish();
                    } else {
                      event.goto(3);
                    }
                    "step 3"
                    if (player.countCards('h') == player.countMark('wenbing3d8')) {
                      player.addMark("wenbing3d8");
                      event.finish();
                    } else {
                      event.goto(4);
                    }

                    "step 4"
                    if (player.countCards('h') < player.countMark('wenbing3d8')) {
                      var num = player.countMark('wenbing3d8') - player.countCards('h');
                      player.draw(num)
                    }
                  },
                  sub: true,
                },
                "2": {
                  audio: "gs_xuanlue",
                  trigger: {
                    player: ["damageBegin4", "loseHpBegin"],
                  },
                  filter: function(event, player) {
                    return player.countMark('wenbing3d8') > 0;
                  },
                  check: function(event, player) {
                    return player.hp <= 2;
                  },
                  prompt: "移去稳兵，免除等量的伤害",
                  content: function() {
                    "step 0"
                    event.num = trigger.num;
                    "step 1"
                    player.removeMark('wenbing3d8');
                    trigger.num--;
                    event.num--;
                    "step 2"
                    if (event.num > 0 && player.countMark("wenbing3d8") > 0) {
                      event.goto(1);
                    } else {
                      event.finish();
                    }
                  },
                  sub: true,
                },
                "3": {
                  audio: "gs_xuanlue",
                  trigger: {
                    player: "recoverBegin",
                  },
                  check: function(event, player) {
                    return player.hp >= 2;
                  },
                  prompt: "取消此次回复，获得等量的稳兵",
                  content: function() {
                    "step 0"
                    player.addMark('wenbing3d8', trigger.num);
                    "step 1"
                    trigger.cancel();
                  },
                  sub: true,
                },
                init: {
                  trigger: {
                    global: "gameDrawAfter",
                    player: "enterGame",
                  },
                  forced: true,
                  locked: false,
                  content: function() {
                    player.addMark("wenbing3d8", 2);
                  },
                  sub: true,
                },
              },
            },

            sili3d8: {
              audio: "jlsg_chaochen",
              trigger: {
                global: "damageEnd",
              },
              direct: true,
              filter: function(event, player) {
                return event.player != player && !player.hasSkill("sili3d82");
              },
              content: function() {
                "step 0"
                player.chooseTarget("是否发动肆立？选择一名角色为目标", function(card, player, target) {
                  return target != trigger.player && target.hp < target.maxHp;
                }).set('ai', function(target) {
                  return get.attitude(player, target);
                });
                "step 1"
                if (result.bool) {
                  player.logSkill("sili3d8", result.targets);
                  player.addTempSkill("sili3d82", "roundStart");
                  result.targets[0].addSkill("sili3d83");
                }
              },
            },
            "sili3d82": {},
            "sili3d83": {
              mark: true,
              marktext: "肆",
              trigger: {
                global: "damageBegin",
              },
              intro: {
                content: "若不是下次受到伤害的角色则回复1点体力",
              },
              forced: true,
              content: function() {
                "step 0"
                if (trigger.player != player) {
                  player.recover();
                }
                "step 1"
                player.removeSkill("sili3d83");
              },
            },

            xintu3d8: {
              audio: "jlsg_quanzheng",
              forced: true,
              trigger: {
                player: "phaseDrawBegin1",
              },
              content: function() {
                "step 0"
                player.storage.xintu3d8 = 0;
                event.cards = get.cards(4);
                game.cardsGotoOrdering(event.cards);
                player.showCards(event.cards);
                "step 1"
                var bool = game.hasPlayer(function(current) {
                  return player.canUse(event.cards[0], current);
                });
                if (bool) {
                  player.chooseUseTarget(event.cards[0], true, false);
                  player.storage.xintu3d8++;
                }
                event.cards.remove(event.cards[0]);
                "step 2"
                if (event.cards.length) event.goto(1);
                "step 3"
                if (player.storage.xintu3d8 >= player.hp) {
                  player.chooseToDiscard("e", true);
                }
                if (player.storage.xintu3d8 > player.hp) {
                  trigger.changeToZero();
                }
                "step 4"
                delete player.storage.xintu3d8;
              },
            },

            xiaxing3d8: {
              trigger: {
                global: ["dying", "phaseBegin"]
              },
              filter: function(event, player) {
                if (player.hasSkill("xiaxing3d82")) return false;
                return player.countCards("h") > 0
              },
              direct: true,
              logTarget: "player",
              content: function() {
                "step 0"
                player.chooseCard(get.prompt2("xiaxing3d8", trigger.player), "he").set("ai", function(card) {
                  var player = _status.event.player;
                  if (get.attitude(player, trigger.player) < 3) return 0;
                  if (event.triggername == "dying" && get.attitude(player, trigger.player) >= 3) return 1;
                  if (event.triggername == "phaseBegin" && trigger.player.countCards("h") > 2 && player.countCards("h") > 2) return 1;
                  return 0;
                });
                "step 1"
                if (result.bool) {
                  player.addTempSkill("xiaxing3d82", "roundStart");
                  player.logSkill("xiaxing3d8", trigger.player);
                  var card = result.cards[0];
                  player.$throw(card, 1000);
                  game.log(player, "将", card, "置于牌堆顶");
                  player.lose(card, ui.cardPile, "visible", "insert");
                } else event.finish();
                "step 2"
                game.delay();
                if (event.triggername == "dying" && game.checkMod({
                    name: "tao",
                    isCard: true
                  }, trigger.player, trigger.player, "unchanged", "cardSavable", trigger.player)) {
                  trigger.player.chooseUseTarget({
                    name: "tao"
                  }, true, "noTargetDelay", "nodelayx");
                }
                if (event.triggername == "phaseBegin" && game.checkMod({
                    name: "jiu",
                    isCard: true
                  }, trigger.player, trigger.player, "unchanged", trigger.player)) {
                  trigger.player.chooseUseTarget({
                    name: "jiu"
                  }, true, "noTargetDelay", "nodelayx");
                }
                "step 3"
                player.addTempSkill("xiaxing3d8_sha", {
                  player: "useCard"
                });
                player.addTempSkill("xiaxing3d8_shan", {
                  player: "useCard"
                });
              },
              subSkill: {
                sha: {
                  enable: "chooseToUse",
                  viewAs: {
                    name: "sha",
                    isCard: true
                  },
                  filterCard: function() {
                    return false
                  },
                  selectCard: -1,
                  mark: false,
                  prompt: "视为使用一张杀",
                  ai: {
                    order: function() {
                      var player = _status.event.player;
                      if (!player.hasShan() && !game.hasPlayer(function(current) {
                          return player.canUse("sha", current) && current.hp == 1 && get.effect(current, {
                            name: "sha"
                          }, player, player) > 0;
                        })) {
                        return 0;
                      }
                      return 2.95;
                    },
                    respondSha: true,
                  }
                },
                shan: {
                  enable: "chooseToUse",
                  viewAs: {
                    name: "shan",
                    isCard: true
                  },
                  mark: false,
                  filterCard: function() {
                    return false
                  },
                  selectCard: -1,
                  prompt: "视为使用一张闪",
                  ai: {
                    order: function() {
                      return 3.15;
                    },
                    respondShan: true,
                  }
                }
              }
            },
            xiaxing3d82: {},
            pingxi3d8: {
              audio: "jlsg_feijun",
              trigger: {
                player: "phaseUseBegin",
              },
              direct: true,
              filter: function(event, player) {
                if (player.countCards('h', 'sha') > 0) return true;
                if (player.storage.wangzhi3d8 && player.storage.wangzhi3d8.length) {
                  var num = game.countPlayer(function(current) {
                    return player.canUse({
                      name: 'sha'
                    }, current, false) && lib.filter.targetEnabled2({
                      name: 'sha'
                    }, player, current);
                  });
                  if (num >= 1) return true;
                }
                return false;
              },
              content: function() {
                'step 0'
                var list = ['重铸杀', '使用杀'];
                event.list = list;
                if (player.countCards('h', 'sha') == 0 && player.storage.wangzhi3d8) {
                  event.list.remove('重铸杀');
                }
                var num = game.countPlayer(function(current) {
                  return player.canUse({
                    name: 'sha'
                  }, current, false) && lib.filter.targetEnabled2({
                    name: 'sha'
                  }, player, current);
                });
                if (num < 1) event.list.remove('使用杀');
                player.chooseControl(event.list, 'cancel2').set('ai', function(evt, player) {
                  var controls = _status.event.controls;
                  var num = game.countPlayer(function(current) {
                    return player.canUse({
                      name: 'sha'
                    }, current, false) && lib.filter.targetEnabled2({
                      name: 'sha'
                    }, player, current) && get.effect(current, {
                      name: 'sha'
                    }, player, player) > 0;
                  });
                  var shaTemplate = {
                    name: 'sha',
                    iscard: true
                  };
                  var num_sha = lib.card['sha'].usable;
                  var sha_limit = game.checkMod(shaTemplate, player, num_sha, 'cardUsable', player);
                  if (player.countCards('h', 'sha') > sha_limit && controls.contains('重铸杀')) {
                    return '重铸杀';
                  }
                  if (controls.contains('使用杀') && num >= 1) {
                    return '使用杀';
                  }
                  if (controls.contains('重铸杀')) {
                    return '重铸杀';
                  }
                  return controls.randomGet();
                }).set('prompt', '平西：请选择一项');
                'step 1'
                player.popup(result.control);
                if (result.control == '使用杀') {
                  player.logSkill('pingxi3d8');
                  game.log(player, "选择了使用杀");
                  event.list.remove('重铸杀');
                  player.chooseToUse(function(card, player) {
                    return card.name == 'sha';
                  });
                  event.goto(3);
                } else if (result.control == 'cancel2') {
                  event.finish();
                  return;
                } else if (result.control == '重铸杀') {
                  player.logSkill('pingxi3d8');
                  game.log(player, "选择了重铸杀");
                  event.list.remove('使用杀');
                  event.choice = result.control;
                  player.chooseCard('h', true, function(card, player) {
                    return card.name == 'sha';
                  });
                }
                'step 2'
                if (result.bool) {
                  player.lose(result.cards, ui.discardPile);
                  player.draw('nodelay');
                }
                'step 3'
                player.chooseTarget('平西：请指定一名角色', true, function(card, player, target) {
                  return player != target;
                }).set('ai', function(target) {
                  return get.attitude(_status.event.player, target);
                });
                'step 4'
                if (result.bool) {
                  event.target = result.targets[0];
                  player.logSkill('pingxi3d8', event.target);
                  player.line(event.target, 'green');
                  var count = game.countPlayer(function(current) {
                    return event.target.canUse({
                      name: 'sha'
                    }, current, false) && lib.filter.targetEnabled2({
                      name: 'sha'
                    }, event.target, current);
                  });
                  if (count < 1) event.list.remove('使用杀');
                  if (event.target.countCards('h', 'sha') == 0) {
                    event.list.remove('使用杀');
                    event.list.remove('重铸杀');
                  }
                  //game.delay(1);
                  event.target.chooseControl(event.list, 'cancel2').set('ai', function(evt, player) {
                    var controls = _status.event.controls;
                    var num = game.countPlayer(function(current) {
                      return event.target.canUse({
                        name: 'sha'
                      }, current, false) && lib.filter.targetEnabled2({
                        name: 'sha'
                      }, event.target, current) && get.effect(current, {
                        name: 'sha'
                      }, event.target, event.target) > 0;
                    });
                    var shaTemplate = {
                      name: 'sha',
                      iscard: true
                    };
                    var num_sha = lib.card['sha'].usable;
                    var sha_limit = game.checkMod(shaTemplate, event.target, num_sha, 'cardUsable', event.target);
                    if (event.target.countCards('h', 'sha') > sha_limit && controls.contains('重铸杀')) {
                      return '重铸杀';
                    }
                    if (controls.contains('使用杀') && num >= 1) {
                      return '使用杀';
                    }
                    if (controls.contains('重铸杀')) {
                      return '重铸杀';
                    }
                    return controls.randomGet();
                  }).set('prompt', '平西：请选择一项');
                }
                'step 5'
                event.target.popup(result.control);
                if (result.control == '使用杀') {
                  game.log(event.target, "选择了使用杀");
                  event.target.chooseToUse(true, function(card, player) {
                    return card.name == 'sha';
                  });
                  event.finish();
                } else if (result.control == 'cancel2') {
                  game.log(event.target, "没有选择");
                  if (event.choice == '重铸杀') {
                    game.log(player, "视为使用杀");
                    player.chooseUseTarget('sha', true);
                  } else {
                    game.log(player, "视为重铸杀");
                    player.draw('nodelay');
                  }
                  event.finish();
                } else if (result.control == '重铸杀') {
                  game.log(event.target, "选择了重铸杀");
                  event.target.chooseCard('h', true, function(card, player) {
                    return card.name == 'sha';
                  });
                }
                'step 6'
                if (result.bool) {
                  event.target.lose(result.cards, ui.discardPile);
                  event.target.draw('nodelay');
                }
              },
            },

            wangzhi3d8: {
              unique: true,
              trigger: {
                player: "gainAfter",
              },
              direct: true,
              init: function(player) {
                player.storage.wangzhi3d8 = [];
              },
              filter: function(event, player) {
                var num = 0;
                for (var i = 0; i < event.cards.length; i++) {
                  if (get.suit(event.cards[i]) == 'spade') num++;
                }
                return event.cards && event.cards.length > 0 && num > 0;
              },
              content: function() {
                "step 0"
                event.cards = trigger.cards.slice(0);
                "step 1"
                player.chooseCard('he', '是否将其中一张♠牌置于你的武将牌上？', function(card, player) {
                  return _status.event.getParent().cards.contains(card) && get.suit(card) == 'spade';
                }).set('ai', function(card) {
                  if (card.name == 'du') return 20;
                  return 8 - get.value(card);
                });
                "step 2"
                if (result.bool) {
                  player.$give(result.cards, player, false);
                  player.storage.wangzhi3d8 = player.storage.wangzhi3d8.concat(result.cards);
                  player.lose(result.cards, ui.special, 'toStorage');
                  player.markSkill('wangzhi3d8');
                  player.syncStorage('wangzhi3d8');
                  game.log(player, '将', result.cards, '置于武将牌上');
                }
              },
              intro: {
                content: "cards",
              },
              group: ["wangzhi3d82", "wangzhi3d83"],
            },
            "wangzhi3d82": {
              trigger: {
                player: "chooseToRespondBegin",
              },
              audio: "jlsg_zhongyong",
              filter: function(event, player) {
                if (event.responded) return false;
                if (!event.filterCard({
                    name: 'shan'
                  }, player, event) && !event.filterCard({
                    name: 'sha'
                  }, player, event)) return false;
                return player.storage.wangzhi3d8 && player.storage.wangzhi3d8.length;
              },
              check: function(event, player) {
                if (player.countCards('h', 'sha') > 0 && event.filterCard({
                    name: 'sha'
                  }, player, event)) return false;
                if (player.countCards('h', 'shan') > 0 && event.filterCard({
                    name: 'shan'
                  }, player, event)) return false;
                return true;
              },
              content: function() {
                "step 0"
                event.num = player.storage.wangzhi3d8.length;
                player.$throw(player.storage.wangzhi3d8, 1000);
                game.cardsDiscard(player.storage.wangzhi3d8);
                player.storage.wangzhi3d8 = [];
                player.syncStorage('wangzhi3d8');
                player.unmarkSkill('wangzhi3d8');
                player.logSkill("wangzhi3d82");
                "step 1"
                trigger.untrigger();
                trigger.responded = true;
                if (trigger.filterCard({
                    name: 'shan',
                    isCard: true
                  })) {
                  trigger.result = {
                    bool: true,
                    card: {
                      name: 'shan',
                      isCard: true
                    }
                  }
                } else {
                  trigger.result = {
                    bool: true,
                    card: {
                      name: 'sha',
                      isCard: true
                    }
                  }
                }
                "step 2"
                player.draw(event.num);
                player.storage.wangzhi3d8.length = 0;
              },
              ai: {
                effect: {
                  target: function(card, player, target, effect) {
                    if (get.tag(card, 'respondShan')) return 0.7;
                    if (get.tag(card, 'respondSha')) return 0.7;
                  },
                },
              },
            },
            "wangzhi3d83": {
              enable: "chooseToUse",
              audio: "jlsg_zhongyong",
              filter: function(event, player) {
                if (!player.storage.wangzhi3d8) return false;
                if (player.storage.wangzhi3d8.length == 0) return false;
                return event.filterCard({
                  name: 'sha'
                }, player, event) || event.filterCard({
                  name: 'shan'
                }, player, event);
              },
              chooseButton: {
                dialog: function(event, player) {
                  var list = [];
                  if (event.filterCard({
                      name: 'sha'
                    }, player, event)) {
                    list.push(['基本', '', 'sha']);
                    list.push(['基本', '', 'sha', 'fire']);
                    list.push(['基本', '', 'sha', 'thunder']);
                  }
                  if (event.filterCard({
                      name: 'shan'
                    }, player, event)) {
                    list.push(['基本', '', 'shan']);
                  }
                  return ui.create.dialog('望志', [list, 'vcard'], 'hidden');
                },
                check: function(button) {
                  var player = _status.event.player;
                  var card = {
                    name: button.link[2],
                    nature: button.link[3]
                  };
                  if (card.name == 'sha') {
                    if (card.nature == 'fire') return 2.95;
                    else if (card.nature == 'fire') return 2.92;
                    else return 2.9;
                  } else if (card.name == 'shan') {
                    return 4;
                  }
                  return 0;
                },
                backup: function(links, player) {
                  return {
                    filterCard: function() {
                      return false;
                    },
                    viewAs: {
                      name: links[0][2],
                      nature: links[0][3],
                      isCard: true
                    },
                    selectCard: -1,
                    popname: true,
                    log: false,
                    precontent: function() {
                      'step 0'
                      event.num = player.storage.wangzhi3d8.length;
                      player.$throw(player.storage.wangzhi3d8, 1000);
                      game.cardsDiscard(player.storage.wangzhi3d8);
                      player.storage.wangzhi3d8 = [];
                      player.syncStorage('wangzhi3d8');
                      player.unmarkSkill('wangzhi3d8');
                      player.logSkill("wangzhi3d83");
                      'step 1'
                      player.draw(event.num);
                      player.storage.wangzhi3d8.length = 0;
                    },
                  }
                },
                prompt: function(links, player) {
                  return '选择' + get.translation(links[0][3] || '') + get.translation(links[0][2]) + '的目标';
                },
              },
              ai: {
                order: 11,
                respondShan: true,
                respondSha: true,
                result: {
                  player: function(player) {
                    var evt = _status.event;
                    console.log(evt);
                    if (evt.parent.name == 'phaseUse' && evt.type == 'phase') {
                      if (player.countCards('h', 'sha') > 0) return 0;
                      return 1;
                    }
                    if (player.countCards('h', 'sha') > 0 && (evt.type == 'respondSha' || (evt.filterCard && evt.filterCard({
                        name: 'sha'
                      }, player, evt)))) return 0;
                    if (player.countCards('h', 'shan') > 0 && (evt.type == 'respondShan' || (evt.filterCard && evt.filterCard({
                        name: 'shan'
                      }, player, evt)))) return 0;
                    return 1;
                  },
                },
              },
            },

            miaoxing3d8: {
              audio: "luoshen",
              group: ["miaoxing3d81", "miaoxing3d82", "miaoxing3d8_draw"],
              trigger: {
                global: "gameDrawAfter",
              },
              init: function(player) {
                player.storage.miaoxing3d81 = [];
                player.storage.miaoxing3d82 = [];
              },
              forced: true,
              content: function() {
                'step 0'
                event.count = player.countCards("h");
                event.cards1 = get.cards(event.count);
                var content = ['水相', event.cards1];
                game.log(player, '观看了第一份“水相”');
                player.chooseControl(["交换", "不交换"], true).set('prompt', '淼形：是否将手牌与“水相”交换？').set('dialog', content).ai = function() {
                  var cards = player.getCards("h");
                  var val1 = 0;
                  var val2 = 0;
                  for (var i = 0; i < cards.length; i++) {
                    val1 += get.value(cards[i]);
                    val2 += get.value(event.cards1[i]);
                  }
                  if (val1 >= val2) return "不交换";
                  return "交换";
                };
                'step 1'
                if (result.control == "交换") {
                  game.log(player, '选择交换手牌与第一份“水相”');
                  var cards = player.getCards("h");
                  player.$give(cards, player, false);
                  player.storage.miaoxing3d81 = player.storage.miaoxing3d81.concat(cards);
                  player.lose(cards, ui.special, 'toStorage');
                  player.markSkill('miaoxing3d81');
                  player.syncStorage('miaoxing3d81');
                  game.log(player, '将', cards, '置于武将牌上');
                  player.gain(event.cards1, 'gain2', 'log');
                } else {
                  game.log(player, '不选择交换手牌与第一份“水相”');
                  player.$give(event.cards1, player, false);
                  player.storage.miaoxing3d81 = player.storage.miaoxing3d81.concat(event.cards1);
                  player.lose(event.cards1, ui.special, 'toStorage');
                  player.markSkill('miaoxing3d81');
                  player.syncStorage('miaoxing3d81');
                  game.log(player, '将', event.cards1, '置于武将牌上');
                }
                'step 2'
                event.cards2 = get.cards(event.count);
                var content = ['水相', event.cards2];
                game.log(player, '观看了第二份“水相”');
                player.chooseControl(["交换", "不交换"], true).set('prompt', '淼形：是否将手牌与“水相”交换？').set('dialog', content).ai = function() {
                  var cards = player.getCards("h");
                  var val1 = 0;
                  var val2 = 0;
                  for (var i = 0; i < cards.length; i++) {
                    val1 += get.value(cards[i]);
                    val2 += get.value(event.cards2[i]);
                  }
                  if (val1 >= val2) return "不交换";
                  return "交换";
                };
                'step 3'
                if (result.control == "交换") {
                  game.log(player, '选择交换手牌与第二份“水相”');
                  var cards = player.getCards("h");
                  player.$give(cards, player, false);
                  player.storage.miaoxing3d82 = player.storage.miaoxing3d82.concat(cards);
                  player.lose(cards, ui.special, 'toStorage');
                  player.markSkill('miaoxing3d82');
                  player.syncStorage('miaoxing3d82');
                  game.log(player, '将', cards, '置于武将牌上');
                  player.gain(event.cards2, 'gain2', 'log');
                } else {
                  game.log(player, '不选择交换手牌与第二份“水相”');
                  player.$give(event.cards2, player, false);
                  player.storage.miaoxing3d82 = player.storage.miaoxing3d82.concat(event.cards2);
                  player.lose(event.cards2, ui.special, 'toStorage');
                  player.markSkill('miaoxing3d82');
                  player.syncStorage('miaoxing3d82');
                  game.log(player, '将', event.cards2, '置于武将牌上');
                }
              },
            },

            miaoxing3d81: {
              marktext: "水",
              intro: {
                content: "cards",
              },
            },

            miaoxing3d82: {
              marktext: "水",
              intro: {
                content: "cards",
              },
            },

            miaoxing3d8_draw: {
              trigger: {
                player: "phaseDrawAfter",
              },
              forced: true,
              audio: "luoshen",
              filter: function(event, player) {
                return player.countCards("h") > 0;
              },
              content: function() {
                'step 0'
                event.count = player.countCards("h");
                event.cards1 = player.storage.miaoxing3d81;
                event.cards2 = player.storage.miaoxing3d82;
                var content = ['水相', event.cards1];
                game.log(player, '观看了第一份“水相”');
                player.chooseControl(["调整", "不调整"], true).set('prompt', '淼形：是否将第一份“水相”调整至' + get.cnNumber(event.count) + '张？')
                  .set('dialog', content).ai = function() {
                    var cards2 = player.storage.miaoxing3d82;
                    var count1 = event.cards1.length - event.count;
                    var count2 = event.cards2.length - event.count;
                    if (count1 >= count2) return "不调整";
                    return "调整";
                  };
                'step 1'
                if (result.control == "调整") {
                  game.log(player, '决定调整第一份“水相”');
                  var count1 = event.cards1.length - event.count;
                  if (count1 == 0) event.finish();
                  if (count1 < 0) {
                    var cards = get.cards(-count1);
                    player.$give(cards, player, false);
                    player.storage.miaoxing3d81 = player.storage.miaoxing3d81.concat(cards);
                    player.lose(cards, ui.special, 'toStorage');
                    player.markSkill('miaoxing3d81');
                    player.syncStorage('miaoxing3d81');
                    game.log(player, '将', cards, '置于武将牌上');
                    event.finish();
                  }
                  if (count1 > 0) {
                    player.chooseButton(['弃置' + get.cnNumber(count1) + '张牌', event.cards1], count1, true)
                      .set('ai', function(button) {
                        return 20 - get.value(button.link);
                      });
                  }
                } else event.goto(3);
                'step 2'
                if (result.bool) {
                  var cards = result.links;
                  player.$throw(cards, 1000);
                  game.cardsDiscard(cards);
                  for (var i = 0; i < cards.length; i++) {
                    player.storage.miaoxing3d81.remove(cards[i]);
                  }
                  player.markSkill('miaoxing3d81');
                  player.syncStorage('miaoxing3d81');
                  event.finish();
                } else event.finish();
                'step 3'
                game.log(player, '决定调整第二份“水相”');
                var count1 = event.cards2.length - event.count;
                if (count1 == 0) event.finish();
                if (count1 < 0) {
                  var cards = get.cards(-count1);
                  player.$give(cards, player, false);
                  player.storage.miaoxing3d82 = player.storage.miaoxing3d82.concat(cards);
                  player.lose(cards, ui.special, 'toStorage');
                  player.markSkill('miaoxing3d82');
                  player.syncStorage('miaoxing3d82');
                  game.log(player, '将', cards, '置于武将牌上');
                  event.finish();
                }
                if (count1 > 0) {
                  player.chooseButton(['弃置' + get.cnNumber(count1) + '张牌', event.cards2], count1, true)
                    .set('ai', function(button) {
                      return 20 - get.value(button.link);
                    });
                }
                'step 4'
                if (result.bool) {
                  var cards = result.links;
                  player.$throw(cards, 1000);
                  game.cardsDiscard(cards);
                  for (var i = 0; i < cards.length; i++) {
                    player.storage.miaoxing3d82.remove(cards[i]);
                  }
                  player.markSkill('miaoxing3d82');
                  player.syncStorage('miaoxing3d82');
                  event.finish();
                } else event.finish();
              }
            },

            fushi3d8: {
              trigger: {
                player: ["useCardEnd", "respondEnd"],
              },
              audio: "qingguo",
              filter: function(event, player) {
                if (player.hasSkill("fushi3d8_empty")) return false;
                if ((!event.card)) return false;
                if (get.type(event.card) != 'basic') return false;
                return true;
              },
              direct: true,
              content: function() {
                'step 0'
                event.count = player.countCards("h");
                event.cards1 = player.storage.miaoxing3d81;
                event.cards2 = player.storage.miaoxing3d82;
                event.flag = 0;
                var content = ['水相', event.cards1];
                game.log(player, '观看了第一份“水相”');
                player.chooseControl(["交换", "不交换"], true).set('prompt', '浮世：是否将手牌与“水相”交换？').set('dialog', content).ai = function() {
                  var cards = player.getCards("h");
                  var val1 = 0;
                  var val2 = 0;
                  for (var i = 0; i < cards.length; i++) {
                    val1 += get.value(cards[i]);
                  }
                  for (var i = 0; i < event.cards1.length; i++) {
                    val2 += get.value(event.cards1[i]);
                  }
                  if (val1 >= val2) return "不交换";
                  return "交换";
                };
                'step 1'
                if (result.control == "交换") {
                  player.logSkill("fushi3d8");
                  event.flag = 1;
                  game.log(player, '选择交换手牌与第一份“水相”');
                  var cards = player.getCards("h");
                  player.$give(cards, player, false);
                  var gain_cards = player.storage.miaoxing3d81;
                  player.storage.miaoxing3d81 = cards;
                  player.lose(cards, ui.special, 'toStorage');
                  player.markSkill('miaoxing3d81');
                  player.syncStorage('miaoxing3d81');
                  game.log(player, '将', cards, '置于武将牌上');
                  player.gain(gain_cards, 'gain2', 'log');
                } else {
                  game.log(player, '不选择交换手牌与第一份“水相”');
                }
                'step 2'
                var content = ['水相', event.cards2];
                game.log(player, '观看了第二份“水相”');
                player.chooseControl(["交换", "不交换"], true).set('prompt', '浮世：是否将手牌与“水相”交换？').set('dialog', content).ai = function() {
                  var cards = player.getCards("h");
                  var val1 = 0;
                  var val2 = 0;
                  for (var i = 0; i < cards.length; i++) {
                    val1 += get.value(cards[i]);
                  }
                  for (var i = 0; i < event.cards2.length; i++) {
                    val2 += get.value(event.cards2[i]);
                  }
                  if (val1 >= val2) return "不交换";
                  return "交换";
                };
                'step 3'
                if (result.control == "交换") {
                  player.logSkill("fushi3d8");
                  event.flag = 1;
                  game.log(player, '选择交换手牌与第二份“水相”');
                  var cards = player.getCards("h");
                  player.$give(cards, player, false);
                  var gain_cards = player.storage.miaoxing3d82;
                  player.storage.miaoxing3d82 = cards;
                  player.lose(cards, ui.special, 'toStorage');
                  player.markSkill('miaoxing3d82');
                  player.syncStorage('miaoxing3d82');
                  game.log(player, '将', cards, '置于武将牌上');
                  player.gain(gain_cards, 'gain2', 'log');
                } else {
                  game.log(player, '不选择交换手牌与第二份“水相”');
                }
                'step 4'
                console.log(event.flag);
                if (event.flag == 0) {
                  event.finish();
                }
                if (event.flag == 1) {
                  player.addTempSkill("fushi3d8_empty", "phaseAfter");
                  player.chooseTarget("浮世：选择一名其他男性角色角色，令其选择是否将手牌与“水相”交换", function(card, player, target) {
                    return target != player && target.sex == 'male' && target.countCards("h") > 0;
                  }, false).ai = function(target) {
                    if (get.attitude(player, target) <= 0) return -1;
                    return Math.max(5 - target.countCards("h"), 1);
                  };
                }
                "step 5"
                if (result.bool) {
                  event.target = result.targets[0];
                  player.logSkill("fushi3d8", event.target);
                  event.cards1 = player.storage.miaoxing3d81;
                  event.cards2 = player.storage.miaoxing3d82;
                  var content = ['水相', event.cards1];
                  game.log(event.target, '观看了第一份“水相”');
                  event.target.chooseControl(["交换", "不交换"], true).set('prompt', '浮世：是否将手牌与“水相”交换？').set('dialog', content).ai = function() {
                    var cards = event.target.getCards("h");
                    var val1 = 0;
                    var val2 = 0;
                    for (var i = 0; i < cards.length; i++) {
                      val1 += get.value(cards[i]);
                    }
                    for (var i = 0; i < event.cards1.length; i++) {
                      val2 += get.value(event.cards1[i]);
                    }
                    if (val1 >= val2) return "不交换";
                    return "交换";
                  };
                } else event.finish();
                'step 6'
                if (result.control == "交换") {
                  game.log(event.target, '选择交换手牌与第一份“水相”');
                  var cards = event.target.getCards("h");
                  event.target.$give(cards, player, false);
                  var gain_cards = player.storage.miaoxing3d81;
                  player.storage.miaoxing3d81 = cards;
                  event.target.lose(cards, ui.special, 'toStorage');
                  player.markSkill('miaoxing3d81');
                  player.syncStorage('miaoxing3d81');
                  game.log(player, '将', cards, '置于武将牌上');
                  event.target.gain(gain_cards, 'gain2', 'log');
                } else {
                  game.log(event.target, '不选择交换手牌与第一份“水相”');
                }
                'step 7'
                var content = ['水相', event.cards2];
                game.log(event.target, '观看了第二份“水相”');
                event.target.chooseControl(["交换", "不交换"], true).set('prompt', '浮世：是否将手牌与“水相”交换？').set('dialog', content).ai = function() {
                  var cards = event.target.getCards("h");
                  var val1 = 0;
                  var val2 = 0;
                  for (var i = 0; i < cards.length; i++) {
                    val1 += get.value(cards[i]);
                  }
                  for (var i = 0; i < event.cards2.length; i++) {
                    val2 += get.value(event.cards2[i]);
                  }
                  if (val1 >= val2) return "不交换";
                  return "交换";
                };
                'step 8'
                if (result.control == "交换") {
                  game.log(event.target, '选择交换手牌与第二份“水相”');
                  var cards = event.target.getCards("h");
                  event.target.$give(cards, player, false);
                  var gain_cards = player.storage.miaoxing3d82;
                  player.storage.miaoxing3d82 = cards;
                  event.target.lose(cards, ui.special, 'toStorage');
                  player.markSkill('miaoxing3d82');
                  player.syncStorage('miaoxing3d82');
                  game.log(player, '将', cards, '置于武将牌上');
                  event.target.gain(gain_cards, 'gain2', 'log');
                } else {
                  game.log(event.target, '不选择交换手牌与第二份“水相”');
                }
              }
            },

            fushi3d8_empty: {},

            fujv13d8: {
              audio: "jlsg_yiji",
              trigger: {
                global: "phaseAfter",
              },
              forced: true,
              filter: function(event, player) {
                return event.player != player &&
                  ((5 - player.storage.disableEquip.length < player.maxHp && player.storage.disableEquip.length > 0) ||
                    (player.hp < player.maxHp && player.hp < player.countCards("h")));
              },
              content: function() {
                'step 0'
                if (5 - player.storage.disableEquip.length < player.maxHp) event.goto(1);
                else event.goto(3);
                'step 1'
                player.chooseToEnable();
                'step 2'
                if (5 - player.storage.disableEquip.length < player.maxHp && player.storage.disableEquip.length > 0) event.goto(1);
                else event.goto(3);
                'step 3'
                if (player.hp < player.maxHp && player.hp < player.countCards("h")) {
                  player.recover(Math.min(player.maxHp - player.hp, player.countCards("h") - player.hp));
                } else event.finish();
              },
            },

            fujv23d8: {
              audio: "jlsg_tianshang",
              group: ["fujv23d8_equip", "fujv23d8_end"],
              trigger: {
                player: "damageBefore",
              },
              forced: true,
              content: function() {
                trigger.cancel();
                player.loseHp(trigger.num);
              },
              ai: {
                noDirectDamage: true,
              },
              subSkill: {
                equip: {
                  audio: "jlsg_tianshang",
                  trigger: {
                    player: "loseEnd",
                  },
                  forced: true,
                  filter: function(event, player) {
                    if (player.equiping) return false;
                    for (var i = 0; i < event.cards.length; i++) {
                      if (event.cards[i].original == 'e') return true;
                    }
                    return false;
                  },
                  content: function() {
                    for (var i = 0; i < trigger.cards.length; i++) {
                      if (trigger.cards[i].original == 'e') player.disableEquip(get.subtype(trigger.cards[i]));
                    }
                  },
                  sub: true,
                },
                end: {
                  audio: "jlsg_tianshang",
                  trigger: {
                    player: "phaseAfter",
                  },
                  forced: true,
                  filter: function(event, player) {
                    return player.hp < player.maxHp;
                  },
                  content: function() {
                    player.loseMaxHp(player.maxHp - player.hp);
                  },
                  sub: true,
                },
              },
            },

            fujv33d8: {
              group: ["fujv33d8_disable", "fujv33d8_lose", "fujv33d8_die"],
              audio: "jlsg_huiqu",
              trigger: {
                player: "loseHpEnd",
              },
              forced: true,
              filter: function(event, player) {
                return event.num > 0 && game.hasPlayer(function(current) {
                  return player != current && current.countCards("he") > 0;
                });
              },
              content: function() {
                'step 0'
                event.num = trigger.num;
                'step 1'
                player.chooseTarget('令一名其他角色弃置一张牌', function(card, player, target) {
                  return player != target && target.countCards('he') > 0;
                }, true).set('ai', function(target) {
                  if (get.attitude(player, target) > 0) return -1;
                  if (get.attitude(player, target) == 0) return 0;
                  return Math.max(1, 5 - target.countCards('he'));
                });
                "step 2"
                if (result.bool) {
                  event.target = result.targets[0];
                  player.line(event.target, 'red');
                  event.target.chooseToDiscard('he', true);
                  event.num -= 1;
                } else event.finish();
                "step 3"
                var has = game.hasPlayer(function(current) {
                  return player != current && current.countCards("he") > 0;
                });
                if (event.num > 0 && has) {
                  event.goto(1);
                } else event.finish();
              },
              subSkill: {
                disable: {
                  audio: "jlsg_huiqu",
                  trigger: {
                    player: "disableEquipAfter",
                  },
                  forced: true,
                  filter: function(event, player) {
                    return true;
                  },
                  content: function() {
                    'step 0'
                    player.chooseTarget('令一名其他角色失去一点体力', function(card, player, target) {
                      return player != target;
                    }, true).set('ai', function(target) {
                      if (get.attitude(player, target) > 0) return -1;
                      if (get.attitude(player, target) == 0) return 0;
                      return Math.max(1, 5 - target.hp);
                    });
                    "step 1"
                    if (result.bool) {
                      event.target = result.targets[0];
                      player.line(event.target, 'red');
                      event.target.loseHp();
                    } else event.finish();
                  },
                },
                lose: {
                  audio: "jlsg_huiqu",
                  trigger: {
                    player: "loseMaxHpAfter",
                  },
                  forced: true,
                  filter: function(event, player) {
                    return event.num > 0 && game.hasPlayer(function(current) {
                      return player != current && player.storage.disableEquip.length < 5;
                    });
                  },
                  content: function() {
                    'step 0'
                    event.num = trigger.num;
                    'step 1'
                    player.chooseTarget('令一名其他角色废除一个装备栏', function(card, player, target) {
                      return player != target && target.storage.disableEquip.length < 5;
                    }, true).set('ai', function(target) {
                      if (get.attitude(player, target) > 0) return -1;
                      if (get.attitude(player, target) == 0) return 0;
                      return -get.attitude(player, target) + target.storage.disableEquip.length;
                    });
                    "step 2"
                    if (result.bool) {
                      event.target = result.targets[0];
                      player.line(event.target, 'red');
                      event.list = [];
                      var list = ['武器栏', '防具栏', '防御马', '进攻马', '宝物栏'];
                      for (var i = 0; i < list.length; i++) {
                        var num = i + 1;
                        if (!event.target.isDisabled(num)) event.list.push(list[i]);
                      }
                      event.target.chooseControl(true, event.list).set('prompt', "请选择你要废除的装备栏").set('ai', function() {
                        if (!player.isDisabled(5)) {
                          return "宝物栏";
                        }
                        if (!player.isDisabled(4)) {
                          return "进攻马";
                        }
                        if (!player.isDisabled(3)) {
                          return "防御马";
                        }
                        if (!player.isDisabled(1)) {
                          return "武器栏";
                        }
                        return "防具栏";
                      });
                    } else event.finish();
                    "step 3"
                    if (result && result.control) {
                      switch (result.control) {
                        case '武器栏':
                          event.denum = 1;
                          break;
                        case '防具栏':
                          event.denum = 2;
                          break;
                        case '防御马':
                          event.denum = 3;
                          break;
                        case '进攻马':
                          event.denum = 4;
                          break;
                        case '宝物栏':
                          event.denum = 5;
                          break;
                      }
                    } else event.finish();
                    'step 4'
                    event.target.disableEquip(event.denum);
                    event.num -= 1;
                    "step 5"
                    var has = game.hasPlayer(function(current) {
                      return player != current && current.storage.disableEquip.length < 5;
                    });
                    if (event.num > 0 && has) {
                      event.goto(1);
                    } else event.finish();
                  },
                },
                die: {
                  audio: "jlsg_huiqu",
                  trigger: {
                    player: "dieBegin",
                  },
                  forced: true,
                  content: function() {
                    'step 0'
                    player.chooseTarget('令一名其他角色失去一点体力上限', function(card, player, target) {
                      return player != target;
                    }, true).set('ai', function(target) {
                      if (get.attitude(player, target) > 0) return -1;
                      if (get.attitude(player, target) == 0) return 0;
                      var val = Math.max(1, 5 - target.maxHp);
                      if (target.maxHp == target.hp) val += 3;
                      return val;
                    });
                    "step 1"
                    if (result.bool) {
                      event.target = result.targets[0];
                      player.line(event.target, 'red');
                      event.target.loseMaxHp();
                    } else event.finish();
                  },
                },
              },
            },

            fenji3d8: {
              audio: "jlsg_yonglie",
              group: ["fenji3d81", "fenji3d82"],
            },
            "fenji3d81": {
              audio: "jlsg_yonglie",
              direct: true,
              trigger: {
                player: "phaseDrawBegin1",
              },
              init: function(player) {
                if (!player.storage.fenji3d8) player.storage.fenji3d8 = [];
              },
              filter: function(event, player) {
                return !event.numFixed;
              },
              content: function() {
                'step 0'
                var list = ['nanman', 'guohe', 'wanjian', 'shunshou', 'juedou', 'wuzhong', 'taoyuan', 'tiesuo', 'wugu', 'jiedao', 'huogong', 'chuqibuyi', 'dongzhuxianji', 'zhujinqiyuan', 'shuiyanqijunx'];
                for (var i = 0; i < player.storage.fenji3d8.length; i++) {
                  list.remove(player.storage.fenji3d8[i]);
                }
                for (var i = 0; i < lib.inpile.length; i++) {
                  var name = lib.inpile[i];
                }
                player.chooseButton(['奋计：请选择要使用的牌名', [list, 'vcard']]).set('ai', function(button) {
                  var player = _status.event.player;
                  if (button.link[2] == 'wugu') return 0;
                  if (button.link[2] == 'wuzhong') return 0.1;
                  var effect = player.getUseValue(button.link[2]);
                  if (effect > 0) {
                    if (get.tag(card, 'damage') == 1) return effect;
                    return effect - 5;
                  }
                  return 0;
                });
                'step 1'
                if (result.bool) {
                  trigger.changeToZero();
                  player.addTempSkill('fenji3d8_draw', 'phaseDrawEnd');
                  player.logSkill('fenji3d8');
                  var name = result.links[0][2];
                  event.vcard = result.links;
                  event.cardname = name;
                  player.storage.fenji3d8.add(name);
                } else {
                  event.finish();
                }
                'step 2'
                if (result.bool) {
                  player.chooseUseTarget(result.links[0][2], true, false);
                }

              },
            },
            "fenji3d82": {
              audio: "jlsg_yonglie",
              direct: true,
              trigger: {
                player: "phaseDiscardBefore",
              },
              init: function(player) {
                if (!player.storage.fenji3d8) player.storage.fenji3d8 = [];
              },
              content: function() {
                'step 0'
                var list = ['nanman', 'guohe', 'wanjian', 'shunshou', 'juedou', 'wuzhong', 'taoyuan', 'tiesuo', 'wugu', 'jiedao', 'huogong', 'chuqibuyi', 'dongzhuxianji', 'zhujinqiyuan', 'shuiyanqijunx'];
                for (var i = 0; i < player.storage.fenji3d8.length; i++) {
                  list.remove(player.storage.fenji3d8[i]);
                }
                for (var i = 0; i < lib.inpile.length; i++) {
                  var name = lib.inpile[i];
                }
                player.chooseButton(['奋计：请选择要使用的牌名', [list, 'vcard']]).set('ai', function(button) {
                  var player = _status.event.player;
                  if (button.link[2] == 'wugu') return 0;
                  var effect = player.getUseValue(button.link[2]);
                  if (effect > 0) {
                    if (!get.tag(card, 'multitarget')) return effect;
                    if (button.link[2] == 'nanman' || button.link[2] == 'wanjian') return effect - (game.filterPlayer().length - 1);
                    if (button.link[2] == 'wugu' || button.link[2] == 'taoyuan') return effect - (game.filterPlayer().length);
                    if (button.link[2] == 'tiesuo') return effect - 2;
                    return effect - 3;
                  }
                  return 0;
                });
                'step 1'
                if (result.bool) {
                  trigger.cancel();
                  player.addTempSkill('fenji3d8_discard');
                  player.logSkill('fenji3d8');
                  var name = result.links[0][2];
                  event.vcard = result.links;
                  event.cardname = name;
                  player.storage.fenji3d8.add(name);
                } else {
                  event.finish();
                }
                'step 2'
                if (result.bool) {
                  player.chooseUseTarget(result.links[0][2], true, false);
                }

              },
            },
            "fenji3d8_discard": {
              trigger: {
                player: "useCardAfter",
              },
              forced: true,
              silent: true,
              popup: false,
              content: function() {
                player.chooseToDiscard(true, trigger.targets.length);
              },
            },
            "fenji3d8_draw": {
              trigger: {
                player: "useCardAfter",
              },
              forced: true,
              silent: true,
              popup: false,
              filter: function(event, player) {
                var num = 0;
                player.getHistory('sourceDamage', function(evt) {
                  if (evt.card == event.card) num += evt.num;
                });
                return num > 0;
              },
              content: function() {
                var num = 0;
                player.getHistory('sourceDamage', function(evt) {
                  if (evt.card == trigger.card) num += evt.num;
                });
                player.draw(num);
              },
            },

            lianer3d8: {
              audio: "qiaoshi",
              trigger: {
                player: "useCardAfter",
              },
              filter: function(event, player) {
                return get.color(event.card) == 'red';
              },
              prompt: function(event, player) {
                return '是否发动【涟洏】获得' + get.translation(event.cards) + '？';
              },
              check: function(event, player) {
                if (get.type(event.card) == 'equip' || get.type(event.card) == 'delay') return false;
                var cards = player.getCards("h");
                if (player.isPhaseUsing()) {
                  for (var i = 0; i < cards.length; i++) {
                    var card = cards[i];
                    if (card.number < event.card.number) continue;
                    var check = game.hasPlayer(function(current) {
                      return player.canUse(card, current) && lib.filter.targetEnabled2(card, player, current) && get.effect(current, card, player, player) > 0;
                    }) && player.getUseValue(card) > 0;
                    if (check && get.value(card) > get.value(event.card)) return false;
                  }
                  return true;
                }
                var shan = 0;
                var pre_tao = 0;
                var pre_shan = 0;
                for (var i = 0; i < cards.length; i++) {
                  var card = cards[i];
                  if (card.name == 'tao' && card.number < event.card.number) return true;
                  if (card.name == 'shan' && card.number < event.card.number) shan = 1;
                  if (card.name == 'tao' && card.number >= event.card.number) pre_tao = 1;
                  if (card.name == 'shan' && card.number >= event.card.number) pre_shan = 1;
                }
                var check = game.hasPlayer(function(current) {
                  return player != current && get.attitude(player, current) > 4 && current.hp == 1;
                });
                if ((player.hp == 1 || check) && get.attitude(player, _status.currentPhase) < 0 && _status.currentPhase.isPhaseUsing() &&
                  pre_tao == 1) return false;
                return true;
              },
              content: function() {
                'step 0'
                event.num = trigger.cards[0].number;
                player.gain(trigger.cards, 'gain2');
                'step 1'
                if (event.num) player.storage.lianer3d82 = event.num;
                player.addTempSkill('lianer3d82');
              },
              mod: {
                aiOrder: function(player, card, num) {
                  if (typeof card.number != 'number') return;
                  if (!player.isPhaseUsing()) return num + 10 * card.number;
                  if (get.color(card) == 'red') return num + 3 * card.number;
                  var cards = player.getCards("h");
                  var number = 0;
                  for (var i = 0; i < cards.length; i++) {
                    number += cards[i].number;
                  }
                  return num + 3 * (number / (cards.length + 0.0));
                },
              },
            },

            lianer3d82: {
              onremove: function(player) {
                delete player.storage.lianer3d82;
              },
              mark: true,
              mod: {
                cardEnabled: function(card, player) {
                  if (card.number >= player.storage.lianer3d82) return false;
                },
                cardSavable: function(card, player) {
                  if (card.number >= player.storage.lianer3d82) return false;
                },
              },
            },

            anzhi3d8: {
              audio: "yanyu",
              group: ["anzhi3d8_discard"],
              trigger: {
                global: "phaseBegin",
              },
              init: function(player) {
                player.storage.anzhi3d8_cards = [];
              },
              filter: function(event, player) {
                if (player.storage.anzhi3d8_cards.length == 0) return false;
                var cards = player.storage.anzhi3d8_cards;
                for (var i = 0; i < cards.length; i++) {
                  if (get.position(cards[i]) == 'd' && get.color(cards[i]) == 'black') return true;
                }
                return false;
              },
              check: function(event, player) {
                return get.attitude(player, event.player) <= 0;
              },
              content: function() {
                'step 0'
                player.chooseTarget('暗织：请选择一名角色', function(card, player, target) {
                  return true;
                }).set('ai', function(target) {
                  var player = _status.event.player;
                  var att = get.attitude(player, target);
                  if (get.attitude(player, trigger.player) <= 0) {
                    if (att <= 0) {
                      if (target != trigger.player) return -1;
                      return -att * Math.min(2, target.countCards("h")) * Math.random();
                    }
                    var buff = 1;
                    if (get.distance(trigger.player, target, 'attack') <= 1) buff = 1.5;
                    if (trigger.player.canUse('sha', target)) return buff * att * Math.max(1, 5 - target.countCards("h")) * Math.max(1, 5 - target.hp) * Math.random();
                    return buff * att * Math.max(1, 5 - target.countCards("h")) * Math.max(1, 5 - target.hp) * Math.random() * 0.5;
                  }
                  if (get.attitude(player, target) > 0 && target.countCards("j") == 0) return 1;
                  return -1;
                });
                'step 1'
                if (result.bool) {
                  game.log(player, "暗中选择了一名角色");
                  player.storage.anzhi3d8_player = result.targets[0];
                  result.targets[0].addTempSkill("anzhi3d8_buff", "phaseAfter");
                  result.targets[0].storage.anzhi3d8_buff_player = player;
                  var players = game.filterPlayer();
                  for (var i = 0; i < players.length; i++) {
                    players[i].storage.anzhi3d8_user = player;
                  }
                } else {
                  game.log(player, "没有选择角色");
                }
              },
              subSkill: {
                discard: {
                  trigger: {
                    global: ["loseAfter", "cardsDiscardAfter"],
                  },
                  forced: true,
                  popup: false,
                  silent: true,
                  filter: function(event, player) {
                    if (event.cards) {
                      for (var i = 0; i < event.cards.length; i++) {
                        if (get.position(event.cards[i]) == 'd') return true;
                      }
                    }
                    return false;
                  },
                  content: function() {
                    player.storage.anzhi3d8_cards = [];
                    for (var i = 0; i < trigger.cards.length; i++) {
                      if (get.position(trigger.cards[i]) == 'd') player.storage.anzhi3d8_cards.push(trigger.cards[i]);
                    }
                  },
                },
              },
            },

            anzhi3d8_buff: {
              global: ["anzhi3d8_user"],
              trigger: {
                target: "useCardToBefore",
              },
              forced: true,
              priority: 15,
              filter: function(event, player) {
                if (get.color(event.card) != 'black') return false;
                if (player.hasSkill("anzhi3d8_buff_temp")) return false;
                return true;
              },
              content: function() {
                player.storage.anzhi3d8_buff_player.logSkill("anzhi3d8", player);
                //trigger.excluded.add(player);
                player.addSkill("anzhi3d8_buff_temp");
                game.log(player.storage.anzhi3d8_buff_player, "令", trigger.player, "的", trigger.card, "对", player, "无效");
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  players[i].storage.anzhi3d8_user_flag = 1;
                }
                trigger.cancel();
              },
              sub: true,
            },

            anzhi3d8_buff_temp: {},

            anzhi3d8_user: {
              ai: {
                effect: {
                  player: function(card, player, target, current) {
                    if (player == player.storage.anzhi3d8_user) {
                      if (player.storage.anzhi3d8_user_flag && player.storage.anzhi3d8_user_flag == 1) return;
                      if (get.color(card) != 'black' && target == player.storage.anzhi3d8_player) return 'zeroplayertarget';
                      return;
                    }
                    if (get.attitude(player, target) < 0 && get.attitude(player, player.storage.anzhi3d8_user) < 0) {
                      if (player.storage.anzhi3d8_user_flag && player.storage.anzhi3d8_user_flag == 1) return;
                      if (get.color(card) != 'black') return;
                      if (Math.random() > 1 - 1 / (2 + target.getFriends().length)) return 'zeroplayertarget';
                    } else if (player == target && get.attitude(player, player.storage.anzhi3d8_user) < 0) {
                      if (player.storage.anzhi3d8_user_flag && player.storage.anzhi3d8_user_flag == 1) return;
                      if (Math.random() > 1 - 1 / (1 + target.getEnemies().length)) return 'zeroplayertarget';
                    }
                  },
                },
              },
            },

            shilie3d8: {
              group: "shilie3d8_shan",
              enable: "chooseToUse",
              viewAs: {
                name: "sha",
                isCard: true,
              },
              filterCard: function() {
                return false
              },
              viewAsFilter: function(player) {
                if (player.hasSkill("shilie3d8_disable")) return false;
                var num1 = _status.currentPhase.hp + player.hp;
                var hs = player.getCards("h", function(card) {
                  return !card.hasGaintag("shilie3d8");
                });
                var num2 = 0;
                for (var i = 0; i < hs.length; i++) {
                  num2 += get.number(hs[i]);
                }
                return num2 >= num1;
              },
              selectCard: -1,
              mark: false,
              precontent: function() {
                "step 0"
                player.addTempSkill("shilie3d8_disable");
                "step 1"
                var num = _status.currentPhase.hp + player.hp;
                var next = player.chooseCard(true, "明置任意张点数之和不小于" + get.cnNumber(num) + "的手牌并视为使用一张【杀】", function(card) {
                  if (card.hasGaintag("shilie3d8")) return false;
                  var num2 = 0;
                  for (var i = 0; i < ui.selected.cards.length; i++) {
                    num2 += get.number(ui.selected.cards[i]);
                  }
                  return get.number(card) + num >= num;
                }, "h");
                next.set("num", num);
                next.set("complexCard", true);
                next.set("selectCard", function() {
                  var num3 = 0;
                  for (var i = 0; i < ui.selected.cards.length; i++) {
                    num3 += get.number(ui.selected.cards[i]);
                  }
                  if (num3 >= num) return [ui.selected.cards.length, Infinity];
                  return ui.selected.cards.length + 2;
                });
                next.set("ai", function(card) {
                  return 10;
                });
                "step 2"
                if (result.bool) {
                  player.showCards(result.cards);
                  player.addGaintag(result.cards, "shilie3d8");
                  player.addSkill("shilie3d8_text");
                  var num = _status.currentPhase.hp + player.hp;
                  var num2 = 0;
                  for (var i = 0; i < result.cards.length; i++) {
                    num2 += get.number(result.cards[i]);
                  }
                  if (num == num2) player.draw(result.cards.length);
                }
              },
              prompt: "视为使用一张杀",
              ai: {
                order: function() {
                  var player = _status.event.player;
                  if (!player.hasShan() && !game.hasPlayer(function(current) {
                      return player.canUse("sha", current) && current.hp == 1 && get.effect(current, {
                        name: "sha"
                      }, player, player) > 0;
                    })) {
                    return 0;
                  }
                  return 2.95;
                },
                respondSha: true,
                yingbian: function(card, player, targets, viewer) {
                  if (get.attitude(viewer, player) <= 0) return 0;
                  var base = 0,
                    hit = false;
                  if (get.cardtag(card, "yingbian_hit")) {
                    hit = true;
                    if (targets.filter(function(target) {
                        return target.hasShan() && get.attitude(viewer, target) < 0 && get.damageEffect(target, player, viewer, get.nature(card)) > 0;
                      })) base += 5;
                  }
                  if (get.cardtag(card, "yingbian_all")) {
                    if (game.hasPlayer(function(current) {
                        return !targets.contains(current) && lib.filter.targetEnabled2(card, player, current) && get.effect(current, card, player, player) > 0;
                      })) base += 5;
                  }
                  if (get.cardtag(card, "yingbian_damage")) {
                    if (targets.filter(function(target) {
                        return get.attitude(player, target) < 0 && (hit || !target.mayHaveShan() || player.hasSkillTag("directHit_ai", true, {
                          target: target,
                          card: card,
                        }, true)) && !target.hasSkillTag("filterDamage", null, {
                          player: player,
                          card: card,
                          jiu: true,
                        })
                      })) base += 5;
                  }
                  return base;
                },
                canLink: function(player, target, card) {
                  if (!target.isLinked() && !player.hasSkill("wutiesuolian_skill")) return false;
                  if (target.mayHaveShan() && !player.hasSkillTag("directHit_ai", true, {
                      target: target,
                      card: card,
                    }, true)) return false;
                  if (player.hasSkill("jueqing") || player.hasSkill("gangzhi") || target.hasSkill("gangzhi")) return false;
                  return true;
                },
                basic: {
                  useful: [5, 3, 1],
                  value: [5, 3, 1],
                },
                result: {
                  target: function(player, target, card, isLink) {
                    var eff = function() {
                      if (!isLink && player.hasSkill("jiu")) {
                        if (!target.hasSkillTag("filterDamage", null, {
                            player: player,
                            card: card,
                            jiu: true,
                          })) {
                          if (get.attitude(player, target) > 0) {
                            return -7;
                          } else {
                            return -4;
                          }
                        }
                        return -0.5;
                      }
                      return -1.5;
                    }();
                    if (!isLink && target.mayHaveShan() && !player.hasSkillTag("directHit_ai", true, {
                        target: target,
                        card: card,
                      }, true)) return eff / 1.2;
                    return eff;
                  },
                },
                tag: {
                  respond: 1,
                  respondShan: 1,
                  damage: function(card) {
                    if (card.nature == "poison") return;
                    return 1;
                  },
                  natureDamage: function(card) {
                    if (card.nature) return 1;
                  },
                  fireDamage: function(card, nature) {
                    if (card.nature == "fire") return 1;
                  },
                  thunderDamage: function(card, nature) {
                    if (card.nature == "thunder") return 1;
                  },
                  poisonDamage: function(card, nature) {
                    if (card.nature == "poison") return 1;
                  },
                },
              },
              subSkill: {
                shan: {
                  enable: "chooseToUse",
                  viewAs: {
                    name: "shan",
                    isCard: true,
                  },
                  filterCard: function() {
                    return false
                  },
                  viewAsFilter: function(player) {
                    if (player.hasSkill("shilie3d8_disable")) return false;
                    var num1 = _status.currentPhase.hp + player.hp;
                    var hs = player.getCards("h", function(card) {
                      return !card.hasGaintag("shilie3d8");
                    });
                    var num2 = 0;
                    for (var i = 0; i < hs.length; i++) {
                      num2 += get.number(hs[i]);
                    }
                    return num2 >= num1;
                  },
                  selectCard: -1,
                  mark: false,
                  precontent: function() {
                    "step 0"
                    player.addTempSkill("shilie3d8_disable");
                    "step 1"
                    var num = _status.currentPhase.hp + player.hp;
                    var next = player.chooseCard(true, "明置任意张点数之和不小于" + get.cnNumber(num) + "的手牌并视为使用一张【闪】", function(card) {
                      if (card.hasGaintag("shilie3d8")) return false;
                      var num2 = 0;
                      for (var i = 0; i < ui.selected.cards.length; i++) {
                        num2 += get.number(ui.selected.cards[i]);
                      }
                      return get.number(card) + num >= num;
                    }, "h");
                    next.set("num", num);
                    next.set("complexCard", true);
                    next.set("selectCard", function() {
                      var num3 = 0;
                      for (var i = 0; i < ui.selected.cards.length; i++) {
                        num3 += get.number(ui.selected.cards[i]);
                      }
                      if (num3 >= num) return [ui.selected.cards.length, Infinity];
                      return ui.selected.cards.length + 2;
                    });
                    next.set("ai", function(card) {
                      return 10;
                    });
                    "step 2"
                    if (result.bool) {
                      player.showCards(result.cards);
                      player.addGaintag(result.cards, "shilie3d8");
                      player.addSkill("shilie3d8_text");
                      var num = _status.currentPhase.hp + player.hp;
                      var num2 = 0;
                      for (var i = 0; i < result.cards.length; i++) {
                        num2 += get.number(result.cards[i]);
                      }
                      if (num == num2) player.draw(result.cards.length);
                    }
                  },
                  prompt: "视为使用一张闪",
                  ai: {
                    respondShan: true,
                    order: 3,
                    basic: {
                      useful: [7, 5.1, 2],
                      value: [7, 5.1, 2],
                    },
                    result: {
                      player: 1,
                    },
                  },
                  sub: true,
                },
                text: {
                  mark: true,
                  intro: {
                    mark: function(dialog, content, player) {
                      var hs = player.getCards("h", function(card) {
                        return card.hasGaintag("shilie3d8");
                      });
                      if (hs.length) dialog.addAuto(hs);
                      else dialog.addText("没有已明置的手牌");
                    },
                  },
                  onremove: function(player) {
                    player.removeGaintag("shilie3d8(");
                  },
                  sub: true,
                },
                disable: {
                  sub: true,
                },
              },
            },

            zhishuc3d8: {
              audio: "jlsg_cangshu",
              trigger: {
                player: "useCard",
              },
              init: function(player) {
                player.storage.zhishuc3d8_mark_wei = 0;
                player.storage.zhishuc3d8_mark_shu = 0;
                player.storage.zhishuc3d8_mark_wu = 0;
                player.storage.zhishuc3d8_mark_qun = 0;
              },
              filter: function(event, player) {
                if (!player.isPhaseUsing()) return false;
                var card = event.card;
                var targets = event.targets;
                if (!targets) return false;
                if (!get.suit(card)) return false;
                var flag = 0;
                var wei = 0;
                var shu = 0;
                var wu = 0;
                var qun = 0;
                for (var i = 0; i < targets.length; i++) {
                  if (targets[i].group == 'wei' || targets[i].group == 'shu' || targets[i].group == 'wu' || targets[i].group == 'qun') flag = 1;
                  if (targets[i].group == 'wei') wei = 1;
                  if (targets[i].group == 'shu') shu = 1;
                  if (targets[i].group == 'wu') wu = 1;
                  if (targets[i].group == 'qun') qun = 1;
                }
                if (flag == 0) return false;
                if (!player.hasSkill("zhishuc3d8_mark")) return true;
                if (player.storage.zhishuc3d8_mark_suits.contains(get.suit(card))) return false;
                if (wei == 1 && player.storage.zhishuc3d8_mark_wei == 0) return true;
                if (shu == 1 && player.storage.zhishuc3d8_mark_shu == 0) return true;
                if (wu == 1 && player.storage.zhishuc3d8_mark_wu == 0) return true;
                if (qun == 1 && player.storage.zhishuc3d8_mark_qun == 0) return true;
                return false;
              },
              check: function(event, player) {
                var players = game.filterPlayer();
                var suit = get.suit(event.card);
                var card = event.card;
                var targets = event.targets;
                var cards = player.getCards("h");
                var list = [];
                for (var i = 0; i < targets.length; i++) {
                  var group = targets[i].group;
                  if (list.contains(group)) continue;
                  list.push(group);
                  for (var j = 0; j < cards.length; j++) {
                    if (cards[j] == card) continue;
                    if (get.suit(card) != suit) continue;
                    var flag = 0;
                    for (var k = 0; k < players.length; k++) {
                      var check = player.canUse(card, players[k]) &&
                        lib.filter.targetEnabled2(card, player, players[k]) && get.effect(players[k], card, player, player) > 0 && player.getUseValue(card) > 0;
                      if (players[k].group != group && check) flag = 1;
                    }
                    if (flag == 0) return true;
                  }
                }
                return false;
              },
              content: function() {
                'step 0'
                event.list = [];
                var targets = trigger.targets;
                for (var i = 0; i < targets.length; i++) {
                  if (targets[i].group == 'wei' && player.storage.zhishuc3d8_mark_wei == 0 && !event.list.contains("wei")) event.list.push("wei");
                  if (targets[i].group == 'shu' && player.storage.zhishuc3d8_mark_shu == 0 && !event.list.contains("shu")) event.list.push("shu");
                  if (targets[i].group == 'wu' && player.storage.zhishuc3d8_mark_wu == 0 && !event.list.contains("wu")) event.list.push("wu");
                  if (targets[i].group == 'qun' && player.storage.zhishuc3d8_mark_qun == 0 && !event.list.contains("qun")) event.list.push("qun");
                }
                player.chooseControl(event.list).set('prompt', '请选择一个势力').ai = function() {
                  var players = game.filterPlayer();
                  var list = [];
                  var wei_val = 0;
                  var shu_val = 0;
                  var wu_val = 0;
                  var qun_val = 0;
                  for (var i = 0; i < event.list.length; i++) {
                    var group = event.list[i];
                    var card = trigger.card;
                    var targets = trigger.targets;
                    var cards = player.getCards("h");
                    var suit = get.suit(trigger.card);
                    for (var j = 0; j < cards.length; j++) {
                      if (cards[j] == card) continue;
                      if (get.suit(card) != suit) continue;
                      var flag = 0;
                      for (var k = 0; k < players.length; k++) {
                        var check = player.canUse(card, players[k]) &&
                          lib.filter.targetEnabled2(card, player, players[k]) && get.effect(players[k], card, player, player) > 0 && player.getUseValue(card) > 0;
                        if (players[k].group != group && check) {
                          flag = 1;
                          if (group == 'wei') wei_val = Math.max(wei_val, player.getUseValue(card));
                          if (group == 'shu') shu_val = Math.max(shu_val, player.getUseValue(card));
                          if (group == 'wu') wu_val = Math.max(wu_val, player.getUseValue(card));
                          if (group == 'qun') qun_val = Math.max(qun_val, player.getUseValue(card));
                        }
                      }
                      if (flag == 0) list.push(group);
                    }
                  }
                  if (list.contains("wei")) return "wei";
                  if (list.contains("wu")) return "wu";
                  if (list.contains("qun")) return "qun";
                  if (list.contains("shu")) return "shu";
                  var min = Math.min(wei_val, shu_val, wu_val, qun_val);
                  if (min == wei_val && event.list.contains("wei")) return "wei";
                  if (min == wu_val && event.list.contains("wu")) return "wu";
                  if (min == qun_val && event.list.contains("qun")) return "qun";
                  if (min == shu_val && event.list.contains("shu")) return "shu";
                  return event.list[0];
                };
                'step 1'
                if (result.control) {
                  player.draw();
                  if (!player.hasSkill("zhishuc3d8_mark")) player.addTempSkill("zhishuc3d8_mark", "phaseUseAfter");
                  player.storage.zhishuc3d8_mark_suits.push(get.suit(trigger.card));
                  if (result.control == 'wei') {
                    player.storage.zhishuc3d8_mark_wei = get.suit(trigger.card);
                    game.log(player, "将", get.translation("wei"), "标记为", get.translation(player.storage.zhishuc3d8_mark_wei));
                    player.markSkill('zhishuc3d8_mark_wei');
                  }
                  if (result.control == 'shu') {
                    player.storage.zhishuc3d8_mark_shu = get.suit(trigger.card);
                    game.log(player, "将", get.translation("shu"), "标记为", get.translation(player.storage.zhishuc3d8_mark_shu));
                    player.markSkill('zhishuc3d8_mark_shu');
                  }
                  if (result.control == 'wu') {
                    player.storage.zhishuc3d8_mark_wu = get.suit(trigger.card);
                    game.log(player, "将", get.translation("wu"), "标记为", get.translation(player.storage.zhishuc3d8_mark_wu));
                    player.markSkill('zhishuc3d8_mark_wu');
                  }
                  if (result.control == 'qun') {
                    player.storage.zhishuc3d8_mark_qun = get.suit(trigger.card);
                    game.log(player, "将", get.translation("qun"), "标记为", get.translation(player.storage.zhishuc3d8_mark_qun));
                    player.markSkill('zhishuc3d8_mark_qun');
                  }
                } else event.finish();
              },
              group: ["zhishuc3d8_init", "zhishuc3d8_remove"],
              subSkill: {
                init: {
                  trigger: {
                    player: "phaseUseBegin",
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    player.storage.zhishuc3d8_mark_wei = 0;
                    player.storage.zhishuc3d8_mark_shu = 0;
                    player.storage.zhishuc3d8_mark_wu = 0;
                    player.storage.zhishuc3d8_mark_qun = 0;
                  },
                },
                remove: {
                  trigger: {
                    player: "phaseUseEnd",
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    player.unmarkSkill('zhishuc3d8_mark_wei');
                    player.unmarkSkill('zhishuc3d8_mark_shu');
                    player.unmarkSkill('zhishuc3d8_mark_wu');
                    player.unmarkSkill('zhishuc3d8_mark_qun');
                  },
                },
              },
            },

            zhishuc3d8_mark: {
              group: ["zhishuc3d8_mark_wei", "zhishuc3d8_mark_shu", "zhishuc3d8_mark_wu", "zhishuc3d8_mark_qun"],
              global: ["zhishuc3d8_buff"],
              init: function(player) {
                player.storage.zhishuc3d8_mark_suits = [];
              },
              subSkill: {
                wei: {
                  marktext: "魏",
                  intro: {
                    content: function(storage, player, skill) {
                      if (player.storage.zhishuc3d8_mark_wei == 0) return "未发动“寻录”";
                      return get.translation(player.storage.zhishuc3d8_mark_wei);
                    },
                  },
                  sub: true,
                },
                shu: {
                  marktext: "蜀",
                  intro: {
                    content: function(storage, player, skill) {
                      if (player.storage.zhishuc3d8_mark_shu == 0) return "未发动“寻录”";
                      return get.translation(player.storage.zhishuc3d8_mark_shu);
                    },
                  },
                  sub: true,
                },
                wu: {
                  marktext: "吴",
                  intro: {
                    content: function(storage, player, skill) {
                      if (player.storage.zhishuc3d8_mark_wu == 0) return "未发动“寻录”";
                      return get.translation(player.storage.zhishuc3d8_mark_wu);
                    },
                  },
                  sub: true,
                },
                qun: {
                  marktext: "群",
                  intro: {
                    content: function(storage, player, skill) {
                      if (player.storage.zhishuc3d8_mark_qun == 0) return "未发动“寻录”";
                      return get.translation(player.storage.zhishuc3d8_mark_qun);
                    },
                  },
                  sub: true,
                },
              },
            },

            zhishuc3d8_buff: {
              mod: {
                playerEnabled: function(card, player, target) {
                  if (!_status.currentPhase.hasSkill("zhishuc3d8_mark")) return;
                  if (!_status.currentPhase.isPhaseUsing()) return;
                  if (player.storage.zhishuc3d8_mark_wei != 0 && player.storage.zhishuc3d8_mark_wei != get.suit(card) && target.group == 'wei') return false;
                  if (player.storage.zhishuc3d8_mark_shu != 0 && player.storage.zhishuc3d8_mark_shu != get.suit(card) && target.group == 'shu') return false;
                  if (player.storage.zhishuc3d8_mark_wu != 0 && player.storage.zhishuc3d8_mark_wu != get.suit(card) && target.group == 'wu') return false;
                  if (player.storage.zhishuc3d8_mark_qun != 0 && player.storage.zhishuc3d8_mark_qun != get.suit(card) && target.group == 'qun') return false;
                  if (!_status.currentPhase.storage.zhishuc3d8_mark_suits.contains(get.suit(card))) return;
                  if (player.storage.zhishuc3d8_mark_wei == get.suit(card) && target.group != 'wei') return false;
                  if (player.storage.zhishuc3d8_mark_shu == get.suit(card) && target.group != 'shu') return false;
                  if (player.storage.zhishuc3d8_mark_wu == get.suit(card) && target.group != 'wu') return false;
                  if (player.storage.zhishuc3d8_mark_qun == get.suit(card) && target.group != 'qun') return false;
                  return;
                },
              },
            },

            xunlu3d8: {
              audio: "jlsg_kanwu",
              trigger: {
                player: "phaseAfter",
              },
              frequent: true,
              content: function() {
                'step 0'
                var list;
                if (_status.characterlist) {
                  list = [];
                  for (var i = 0; i < _status.characterlist.length; i++) {
                    var name = _status.characterlist[i];
                    if (lib.character[name][1] == 'wei' || lib.character[name][1] == 'shu' || lib.character[name][1] == 'wu' || lib.character[name][1] == 'qun') list.push(name);
                  }
                }
                var players = game.players.concat(game.dead);
                for (var i = 0; i < players.length; i++) {
                  list.remove(players[i].name);
                  list.remove(players[i].name1);
                  list.remove(players[i].name2);
                }
                var p = list.randomGets(1);
                event.p = p;
                game.log(player, "展示了", p, "，势力为", lib.character[p][1]);
                if (lib.character[p][1] == 'wei' && player.storage.zhishuc3d8_mark_wei != 0) event.suit = player.storage.zhishuc3d8_mark_wei;
                if (lib.character[p][1] == 'shu' && player.storage.zhishuc3d8_mark_shu != 0) event.suit = player.storage.zhishuc3d8_mark_shu;
                if (lib.character[p][1] == 'wu' && player.storage.zhishuc3d8_mark_wu != 0) event.suit = player.storage.zhishuc3d8_mark_wu;
                if (lib.character[p][1] == 'qun' && player.storage.zhishuc3d8_mark_qun != 0) event.suit = player.storage.zhishuc3d8_mark_qun;
                'step 1'
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  var dialog = ui.create.dialog('请确认' + get.translation(player) + "展示的武将牌", 'hidden');
                  dialog.add([
                    [event.p], 'character'
                  ]);
                  players[i].chooseButton(dialog, true);
                }
                'step 2'
                if (!event.suit) event.goto(4);
                event.list = [];
                for (var i = 0; i < ui.discardPile.childElementCount; i++) {
                  var node = ui.discardPile.childNodes[i];
                  if (get.suit(node) == event.suit) event.list.push(node);
                }
                if (event.list.length == 0) event.goto(4);
                else {
                  player.chooseButton(['获得一张牌', event.list])
                    .set('filterButton', function(button) {
                      return true;
                    })
                    .set('ai', function(button) {
                      if (player.hp == 1 && player.countCards("h") <= 1) return get.useful(button.link);
                      return get.value(button.link);
                    });
                }
                'step 3'
                if (result.bool) {
                  player.gain(result.links[0], "gain");
                }
                event.finish();
                'step 4'
                player.phaseUse();
              },
            },

            nishi3d8: {
              audio: "mobiledanshou",
              trigger: {
                player: "phaseZhunbeiBegin",
              },
              forced: true,
              content: function() {
                'step 0'
                var players = game.filterPlayer();
                var min = player.countCards("h");
                for (var i = 0; i < players.length; i++) {
                  min = Math.min(players[i].countCards("h"), min);
                }
                if (min == player.countCards("h")) {
                  var min = Infinity;
                  for (var i = 0; i < players.length; i++) {
                    if (players[i] == player) continue;
                    min = Math.min(players[i].countCards("h"), min);
                  }
                  player.draw(min + 1 - player.countCards("h"));
                }
                'step 1'
                player.chooseTarget(true, '逆势：选择一名手牌少于你的角色，与其交换手牌', function(card, player, target) {
                  return target.countCards("h") < player.countCards("h") && target != player;
                }).set('ai', function(target) {
                  var player = _status.event.player;
                  if (!player.hasSkill("fujiang3d8")) {
                    if (get.attitude(player, target) > 0) return get.attitude(player, target) + 10;
                    else return 5 - (player.countCards("h") - target.countCards("h"));
                  }
                  if (get.attitude(player, target) < 0) {
                    if (!target.hasFriend() && !player.countCards('h', 'tao') && !player.countCards('h', 'jiu') &&
                      !target.hasSkillTag("save") && target.countCards("e") == 0) return 10;
                    if (player.countCards("h") - target.countCards("h") == 1 && target.countCards("e") == 0 &&
                      !player.countCards('h', 'tao') && get.damageEffect(target, player, player) > 0) return Math.max(1, 4 - target.hp);
                    return -1;
                  }
                  if (get.attitude(player, target) == 0) return 0;
                  return Math.max(1, 3 - target.hp);
                });
                'step 2'
                if (result.bool) {
                  var target = result.targets[0];
                  player.line(target, 'green');
                  player.swapHandcards(target);
                }
              },
            },

            fujiang3d8: {
              audio: "mobiledanshou",
              trigger: {
                global: "gainAfter",
              },
              check: function(event, player) {
                if (get.damageEffect(event.player, player, player) > 0 && event.player.countCards("e") == 0) return true;
                return get.attitude(player, event.player) < 0;
              },
              filter: function(event, player) {
                if (event.source == player && event.player != player) {
                  if (event.cards && event.cards.length > 0) return true;
                }
                return false;
              },
              logTarget: "player",
              content: function() {
                "step 0"
                if (!trigger.player.countCards('e')) {
                  player.line(trigger.player, 'green');
                  trigger.player.damage();
                  event.finish();
                }
                "step 1"
                player.discardPlayerCard(trigger.player, get.prompt('fujiang3d8', trigger.player), 'e').set('ai', function(button) {
                  return get.value(button.link);
                });
              },
            },

            sansi3d8: {
              audio: "zhiheng",
              init: function(player) {
                player.storage.sansi3d8_array = ["0", "1", "2"];
              },
              zhuanhuanji: true,
              mark: true,
              intro: {
                content: function(storage, player, skill) {
                  var str = "令一名角色摸三张牌";
                  if (player.storage.sansi3d8_array[0] == "0") return '你可以重铸两张牌，' + str;
                  else if (player.storage.sansi3d8_array[0] == "1") return '你可以重铸三种类别的牌，' + str;
                  else if (player.storage.sansi3d8_array[0] == "2") return '你可以重铸四种花色的牌，' + str;
                },
              },
              enable: "phaseUse",
              usable: 1,
              position: 'he',
              filter: function(event, player) {
                if (player.storage.sansi3d8_array[0] == "0") return player.countCards("he") >= 2;
                if (player.storage.sansi3d8_array[0] == "1") {
                  return player.countCards("he", {
                    type: "basic"
                  }) > 0 && player.countCards("he", {
                    type: "equip"
                  }) > 0 && player.countCards("he", {
                    type: "trick"
                  }) + player.countCards("he", {
                    type: "delay"
                  }) > 0;
                }
                if (player.storage.sansi3d8_array[0] == "2") {
                  if (player.countCards("he", {
                      suit: "spade"
                    }) > 0 && player.countCards("he", {
                      suit: "heart"
                    }) > 0 && player.countCards("he", {
                      suit: "diamond"
                    }) > 0 && player.countCards("he", {
                      suit: "club"
                    }) > 0) {
                    return true;
                  }
                }
                return false;
              },
              check: function(card) {
                return 9 - get.value(card);
              },
              selectCard: function() {
                var player = _status.event.player;
                if (player.storage.sansi3d8_array[0] == "0") return 2;
                if (player.storage.sansi3d8_array[0] == "1") return 3;
                return 4;
              },
              filterCard: function(card) {
                var player = _status.event.player;
                var cards = ui.selected.cards;
                if (player.storage.sansi3d8_array[0] == "0") return true;
                if (player.storage.sansi3d8_array[0] == "1") {
                  for (var i = 0; i < cards.length; i++) {
                    if (get.type(cards[i]) == 'basic' && get.type(card) == 'basic') return false;
                    if (get.type(cards[i]) == 'equip' && get.type(card) == 'equip') return false;
                    if ((get.type(cards[i]) == 'trick' || get.type(cards[i]) == 'delay') && (get.type(card) == 'trick' || get.type(card) == 'delay')) return false;
                  }
                  return true;
                }
                if (player.storage.sansi3d8_array[0] == "2") {
                  for (var i = 0; i < cards.length; i++) {
                    if (get.suit(cards[i]) == get.suit(card)) return false;
                  }
                  return true;
                }
                return false;
              },
              content: function() {
                'step 0'
                if (player.storage.sansi3d8_array[0] == "0") event.count = 2;
                else if (player.storage.sansi3d8_array[0] == "1") event.count = 3;
                else event.count = 4;
                player.draw(event.count);
                player.chooseTarget('请选择一名角色，令其摸三张牌', function(card, player, target) {
                  return true;
                }, true).set('ai', function(target) {
                  if (get.attitude(player, target) <= 0) return -1;
                  if (target.hasJudge('lebu')) return 1;
                  return get.attitude(player, target) + Math.max(5 - target.countCards("h"), 1);
                });
                'step 1'
                if (result.bool) {
                  player.line(result.targets, "green");
                  result.targets[0].draw(3);
                }
                'step 2'
                var temp = player.storage.sansi3d8_array.shift();
                player.storage.sansi3d8_array.push(temp);
                player.syncStorage('sansi3d8_array');
                player.markSkill('sansi3d8_players');
              },
              ai: {
                order: 8,
                result: {
                  player: function(player, target) {
                    return 1;
                  },
                },
              },
            },

            jiezhong3d8: {
              audio: "jieming",
              trigger: {
                global: "dying",
              },
              mark: true,
              intro: {
                content: function(storage, player, skill) {
                  if (player.hasSkill("jiezhong3d8_empty")) return "已发动";
                  return "未发动";
                },
              },
              filter: function(event, player) {
                return !player.hasSkill("jiezhong3d8_empty") && event.player != player;
              },
              check: function(event, player) {
                if (get.attitude(player, event.player) <= 0) return false;
                if (player.storage.sansi3d8_array[0] != "2") return true;
                if (player.hp == 1 && player.countCards("h", {
                    name: "tao"
                  }) == 0 && player.countCards("h", {
                    name: "jiu"
                  }) == 0) {
                  return get.attitude(player, event.player) > 4 || event.player == get.zhu(player);
                }
                return true;
              },
              content: function() {
                'step 0'
                player.logSkill("jiezhong3d8", trigger.player);
                trigger.player.recover(1 - trigger.player.hp);
                if (!player.hasSkill("sansi3d8")) event.finish();
                'step 1'
                game.log(player, "转换了“三思”的状态");
                var temp = player.storage.sansi3d8_array.shift();
                player.storage.sansi3d8_array.push(temp);
                player.syncStorage('sansi3d8_array');
                player.markSkill('sansi3d8_players');
                'step 2'
                if (player.storage.sansi3d8_array[0] == "0") {
                  player.addTempSkill("jiezhong3d8_empty", "roundStart");
                  player.loseHp();
                } else if (player.storage.sansi3d8_array[0] == "1") {
                  player.addTempSkill("jiezhong3d8_empty", "roundStart");
                } else if (player.storage.sansi3d8_array[0] == "2") {
                  game.log(player, "重置了“竭忠”");
                }
              },
              ai: {
                expose: 0.7,
                threaten: 1.5,
              },
            },

            jiezhong3d8_empty: {},

            tunshou3d8: {
              audio: "wangong",
              trigger: {
                player: "phaseUseBegin",
              },
              check: function(event, player) {
                if (player.hp == 1 && player.countCards('h') <= 1) return true;
                if (player.hp == 2 && player.countCards('h') <= 2) {
                  if (Math.random() > 0.5) return true;
                }
                var can_use = 0;
                var liannu = player.getEquip("zhuge");
                var players = game.filterPlayer();
                var cards = player.getCards("h");
                var damage = 0;
                var useful = 0;
                for (var i = 0; i < cards.length; i++) {
                  var card = cards[i];
                  if (get.tag(card, 'damage') && card.name != 'sha' && player.getUseValue(card) > 0) damage += 1;
                  if ((get.type(card) == 'trick' || get.type(card) == 'delay') && card.name != 'wuzhong' && player.getUseValue(card) > player.getUseValue({
                      name: "guohe"
                    })) useful += 1;
                }
                var can_sha = 0;
                var can_kill = 0;
                var risk = 0;
                var can_use = 0;
                for (var i = 0; i < players.length; i++) {
                  var current = players[i];
                  if (get.attitude(player, current) < 0 && current.hp == 1) risk += 1;
                  for (var j = 0; j < cards.length; j++) {
                    var card = cards[j];
                    if (card.name != 'sha') continue;
                    if (player.canUse(card, current) && get.effect(current, card, player, player) > 0) {
                      can_sha = 1;
                      if (current.hp == 1) can_kill = 1;
                    }
                    if (player.canUse(card, current) && current.countCards("he") > 0) {
                      can_use = 1;
                    }
                  }
                }
                if (can_sha == 1 && can_kill == 0) {
                  if (damage == 0 && Math.random() > 0.7) return false;
                  if (damage >= 1 && Math.random() > 0.5) return false;
                  if (can_use == 0) return false;
                  return true;
                } else if (can_kill == 1) {
                  if (damage >= 1) return false;
                  if (can_use == 0) return false;
                  return Math.random() > 0.7;
                } else if (damage == 2) {
                  if (can_use == 0) return false;
                  if (risk > 0) return Math.random() > 0.8;
                  return Math.random() > 0.6;
                } else if (damage == 3) {
                  if (can_use == 0) return false;
                  if (risk > 0) return false;
                  return Math.random() > 0.8;
                }
                if (useful >= 3) return false;
                if (useful == 2) return Math.random() > 0.5;
                if (player.hp == 1 || player.countCards('h') <= 1) return true;
                if (player.hp == 2 || player.countCards('h') <= 2) {
                  if (Math.random() > 0.3) return true;
                }
                return true;
              },
              content: function() {
                player.draw(2);
                player.addTempSkill('tunshou3d82');
                player.addTempSkill('tunshou3d83');
              },
            },

            tunshou3d82: {
              popup: false,
              global: ["tunshou3d82_buff"],
              trigger: {
                player: "useCardToBefore",
              },
              init: function(player) {
                player.storage.tunshou3d82 = [];
                player.storage.tunshou3d82_number = 0;
              },
              marktext: "屯",
              intro: {
                content: "cardCount",
              },
              forced: true,
              filter: function(event, player) {
                return player.hasSkill('tunshou3d8');
              },
              content: function() {
                'step 0'
                if (trigger.target == player) {
                  event.goto(3);
                } else trigger.cancel();
                'step 1'
                player.choosePlayerCard(trigger.target, '屯守：选择一张牌扣置于你的武将牌上', 'he', true).set('ai', function(button) {
                  return get.value(button.link);
                });
                'step 2'
                if (result.bool) {
                  trigger.target.$give(result.cards, player, false);
                  trigger.target.lose(result.cards, ui.special);
                  player.storage.tunshou3d82 = player.storage.tunshou3d82.concat(result.cards);
                  player.syncStorage('tunshou3d82');
                  player.markSkill('tunshou3d82');
                  game.log(player, '将', trigger.target, '的一张牌扣置于武将牌上');
                }
                'step 3'
                if (!player.isPhaseUsing()) event.finish();
                if (!trigger.card) event.finish();
                if (player.storage.tunshou3d82_number < get.number(trigger.card) && player.storage.tunshou3d82_number != 0) {
                  player.storage.tunshou3d82_number = get.number(trigger.card);
                  if (player.storage.tunshou3d82.length > 0) event.goto(4);
                  else event.finish();
                } else {
                  player.storage.tunshou3d82_number = get.number(trigger.card);
                  event.finish();
                }
                'step 4'
                player.logSkill("tunshou3d8");
                var index = Math.floor(Math.random() * player.storage.tunshou3d82.length);
                var card = player.storage.tunshou3d82[index];
                player.storage.tunshou3d82.splice(index, 1);
                player.syncStorage('tunshou3d82');
                player.markSkill('tunshou3d82');
                player.storage.tunshou3d83 = player.storage.tunshou3d83.concat(card);
                game.log(player, '翻开了', card);
                player.syncStorage('tunshou3d83');
                player.markSkill('tunshou3d83');
              },
              group: ["tunshou3d82_gain"],
              subSkill: {
                gain: {
                  trigger: {
                    player: "phaseJieshuBegin",
                  },
                  forced: true,
                  popup: false,
                  filter: function(event, player) {
                    return (player.storage.tunshou3d82 && player.storage.tunshou3d82.length) || (player.storage.tunshou3d83 && player.storage.tunshou3d83.length);
                  },
                  content: function() {
                    if (player.storage.tunshou3d83 && player.storage.tunshou3d83.length) {
                      player.gain(player.storage.tunshou3d83, 'fromStorage');
                      game.log(player, '获得了', player.storage.tunshou3d83);
                      player.storage.tunshou3d83 = [];
                      player.syncStorage('tunshou3d83');
                      player.unmarkSkill('tunshou3d83');
                    }

                    if (player.storage.tunshou3d82 && player.storage.tunshou3d82.length) {
                      player.$throw(player.storage.tunshou3d82, 1000);
                      game.cardsDiscard(player.storage.tunshou3d82);
                      game.log(player, '弃置了', player.storage.tunshou3d82);
                      player.storage.tunshou3d82 = [];
                      player.syncStorage('tunshou3d82');
                      player.unmarkSkill('tunshou3d82');
                    }
                  },
                  sub: true,
                },
              },
              ai: {
                effect: {
                  player: function(card, player, target, current) {
                    if (card.name != 'jiu') return;
                    if (_status.event.dying) return;
                    return [0, 0];
                  },
                },
              },
              mod: {
                aiOrder: function(player, card, num) {
                  if (typeof card.number != 'number') return;
                  if (!player.isPhaseUsing()) return;
                  if (player.storage.tunshou3d82_number == 0) return num + 10 * (14 - card.number);
                  var num = player.storage.tunshou3d82_number;
                  if (card.number > num) return num + 10 * (14 - card.number);
                },
              },
            },

            tunshou3d82_buff: {
              popup: false,
              ai: {
                effect: {
                  target: function(card, player, target, current) {
                    if (player == target || !player.hasSkill("tunshou3d82")) return;
                    if (target.countCards("he") == 0) return [0, 0];
                    return [0, -2];
                  },
                },
              },
            },

            tunshou3d83: {
              popup: false,
              init: function(player) {
                player.storage.tunshou3d83 = [];
              },
              marktext: "屯",
              intro: {
                content: "cards",
              },
            },

            shixing3d8: {
              audio: "tuxing",
              group: ["shixing3d8_trick", "shixing3d8_init"],
              forced: true,
              derivation: ["xiangle", "rejiushi", "rezhiheng"],
              trigger: {
                global: ["gameStart", "dieAfter", "useSkillAfter", "phaseBefore","phaseBegin", "initAfter","shaBegin"],
              },
              filter: function(event, player) {
                var players = game.filterPlayer();
                var flag = 0;
                for (var i = 0; i < players.length; i++) {
                  if (players[i].sex == 'female') flag = 1;
                }
                if (flag == 1 && !player.hasSkill("xiangle")) return true;
                if (flag == 0 && player.hasSkill("xiangle")) return true;
                return false;
              },
              content: function() {
                var players = game.filterPlayer();
                var flag = 0;
                for (var i = 0; i < players.length; i++) {
                  if (players[i].sex == 'female') flag = 1;
                }
                if (flag == 1 && !player.hasSkill("xiangle")) {
                  player.addSkill("xiangle");
                  if (player.hasSkill("rezhiheng")) player.removeSkill("rezhiheng");
                } else if (flag == 0 && player.hasSkill("xiangle")) {
                  player.removeSkill("xiangle");
                  if (!player.hasSkill("rezhiheng") && !player.hasSkill("rejiushi")) player.addSkill("rezhiheng");
                }
              },
              subSkill: {
                init: {
                  audio: "tuxing",
                  trigger: {
                    global: "phaseBegin",
                  },
                  forced: true,
                  filter: function(event, player) {
                    return !player.hasSkill("rejiushi");
                  },
                  content: function() {
                    player.addSkill("rejiushi");
                    if (player.hasSkill("rezhiheng")) player.removeSkill("rezhiheng");
                  },
                },
                trick: {
                  audio: "tuxing",
                  trigger: {
                    global: "useCardAfter",
                  },
                  forced: true,
                  filter: function(event, player) {
                    if (get.type(event.card) != 'trick' && get.type(event.card) != 'delay') return false;
                    return player.hasSkill("rejiushi");
                  },
                  content: function() {
                    player.removeSkill("rejiushi");
                    if (!player.hasSkill("rezhiheng") && !player.hasSkill("xiangle")) player.addSkill("rezhiheng");
                  },
                },
              },
            },

            danggu3d8: {
              audio: "yujue",
              trigger: {
                player: "phaseJieshuBegin",
              },
              filter: function(event, player) {
                return game.hasPlayer(function(current) {
                  return !current.isLinked();
                });
              },
              check: function(event, player) {
                return game.hasPlayer(function(current) {
                  return !current.isLinked() && get.attitude(player, current) < 0;
                });
              },
              content: function() {
                "step 0"
                var num = game.countPlayer(function(current) {
                  return !current.isLinked();
                });
                var count = game.countPlayer(function(current) {
                  return current.group == 'qun';
                });
                player.chooseTarget(get.prompt('danggu3d8'), '横置至多' + get.cnNumber(Math.min(num, count)) + '名未横置的角色', [1, Math.min(num, count)], function(card, player, target) {
                  return !target.isLinked();
                }).set('ai', function(target) {
                  return -get.attitude(_status.event.player, target);
                });
                "step 1"
                if (result.bool) {
                  player.logSkill('danggu3d8', result.targets);
                  event.targets = result.targets;
                  event.num = 0;
                } else {
                  event.finish();
                }
                "step 2"
                if (event.num < event.targets.length) {
                  event.targets[event.num].link();
                  event.num++;
                  event.redo();
                }
              },
              ai: {
                expose: 0.3,
              },
              group: "danggu3d8_linked",
              subSkill: {
                linked: {
                  trigger: {
                    global: "phaseDiscardBegin",
                  },
                  filter: function(event, player) {
                    return event.player.isLinked() && event.player != player && event.player.countCards("he") > event.player.getHandcardLimit();
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    player.logSkill("yujue", trigger.player);
                    trigger.player.chooseToDiscard("党锢：弃置牌至" + get.cnNumber(trigger.player.getHandcardLimit()) + "张", trigger.player.countCards("he") - trigger.player.getHandcardLimit(), 'he', true);
                  },
                  sub: true,
                },
              },
            },

            zhangchuan3d8: {
              group: ["zhangchuan3d8_wuxie", "zhangchuan3d8_shan", "zhangchuan3d8_respond"],
              subSkill: {
                wuxie: {
                  audio: "mibei",
                  sub: true,
                  position: "hes",
                  enable: "chooseToUse",
                  filterCard: function(card) {
                    var players = game.filterPlayer();
                    var black = 0;
                    var red = 0;
                    for (var i = 0; i < players.length; i++) {
                      var cards = players[i].getCards("ej");
                      for (var j = 0; j < cards.length; j++) {
                        if (get.color(cards[j]) == 'black') black += 1;
                        if (get.color(cards[j]) == 'red') red += 1;
                      }
                    }
                    if (black > red) return get.color(card) == 'black';
                    if (red > black) return get.color(card) == 'red';
                    return false;
                  },
                  viewAsFilter: function(player) {
                    return game.hasPlayer(function(current) {
                      return current.countCards('ej');
                    });
                  },
                  viewAs: {
                    name: "wuxie",
                  },
                  prompt: "将一张场上多数颜色的牌当无懈可击使用",
                  check: function(card) {
                    return 6 - get.value(card)
                  },
                  ai: {
                    basic: {
                      useful: [6, 4],
                      value: [6, 4],
                    },
                    result: {
                      player: 1,
                    },
                    expose: 0.2,
                  },
                },
                shan: {
                  audio: "mibei",
                  sub: true,
                  enable: ["chooseToRespond", "chooseToUse"],
                  filterCard: function(card) {
                    var players = game.filterPlayer();
                    var black = 0;
                    var red = 0;
                    for (var i = 0; i < players.length; i++) {
                      var cards = players[i].getCards("ej");
                      for (var j = 0; j < cards.length; j++) {
                        if (get.color(cards[j]) == 'black') black += 1;
                        if (get.color(cards[j]) == 'red') red += 1;
                      }
                    }
                    if (black > red) return get.color(card) == 'black';
                    if (red > black) return get.color(card) == 'red';
                    return false;
                  },
                  position: "hes",
                  viewAs: {
                    name: "shan",
                  },
                  viewAsFilter: function(player) {
                    return game.hasPlayer(function(current) {
                      return current.countCards('ej');
                    });
                  },
                  prompt: "将一张场上多数颜色的牌当闪使用或打出",
                  check: function() {
                    return 1
                  },
                  ai: {
                    respondShan: true,
                    skillTagFilter: function(player) {
                      var players = game.filterPlayer();
                      var black = 0;
                      var red = 0;
                      for (var i = 0; i < players.length; i++) {
                        var cards = players[i].getCards("ej");
                        for (var j = 0; j < cards.length; j++) {
                          if (get.color(cards[j]) == 'black') black += 1;
                          if (get.color(cards[j]) == 'red') red += 1;
                        }
                      }
                      if (black == red) return false;
                    },
                    effect: {
                      target: function(card, player, target, current) {
                        if (get.tag(card, 'respondShan') && current < 0) return 0.6;
                      },
                    },
                    order: 3,
                    basic: {
                      useful: [7, 2],
                      value: [7, 2],
                    },
                    result: {
                      player: 1,
                    },
                  },
                },
                respond: {
                  audio: "mibei",
                  sub: true,
                  unique: true,
                  trigger: {
                    global: ["chooseToRespondBefore", "chooseToUseBefore"],
                  },
                  filter: function(event, player) {
                    if (event.player == player) return false;
                    if (event.responded) return false;
                    if (!event.filterCard({
                        name: 'shan'
                      }, player, event)) return false;
                    if (event.player.countCards('h') >= player.countCards('h')) return false;
                    return true;
                  },
                  check: function(event, player) {
                    if (event.parent && event.parent.player && get.damageEffect(event.player, event.parent.player, player) >= 0) return false;
                    if (get.damageEffect(event.player, player, player) >= 0) return false;
                    if (get.attitude(player, event.player) - 2 <= 0) return false;
                    var players = game.filterPlayer();
                    var black = 0;
                    var red = 0;
                    for (var i = 0; i < players.length; i++) {
                      var cards = players[i].getCards("ej");
                      for (var j = 0; j < cards.length; j++) {
                        if (get.color(cards[j]) == 'black') black += 1;
                        if (get.color(cards[j]) == 'red') red += 1;
                      }
                    }
                    var cards = player.getCards("he");
                    for (var i = 0; i < cards.length; i++) {
                      if (cards[i].name == 'shan') return true;
                      if (get.color(cards[i]) == 'black' && black > red && get.value(cards[i]) < 8) return true;
                      if (get.color(cards[i]) == 'red' && black < red && get.value(cards[i]) < 8) return true;
                    }
                    return false;
                  },
                  content: function() {
                    "step 0"
                    player.chooseToRespond('是否替' + get.translation(trigger.player) + '打出一张闪？', {
                      name: 'shan'
                    });
                    "step 1"
                    if (result.bool) {
                      event.finish();
                      trigger.result = {
                        bool: true,
                        card: {
                          name: 'shan'
                        }
                      };
                      trigger.responded = true;
                    }
                  },
                }
              },
              ai: {
                expose: 0.2,
              },
            },


            xingbian3d8: {
              audio: "xingqi",
              limited: true,
              skillAnimation: true,
              animationColor: "gray",
              init: function(player) {
                if (!player.storage.xingbian3d8) player.storage.xingbian3d8 = [];
              },
              trigger: {
                player: "phaseAfter",
              },
              derivation: ["huilan3d8"],
              filter: function(event, player) {
                var players = game.filterPlayer();
                var black = 0;
                var red = 0;
                for (var i = 0; i < players.length; i++) {
                  var cards = players[i].getCards("ej");
                  for (var j = 0; j < cards.length; j++) {
                    if (get.color(cards[j]) == 'black') black += 1;
                    if (get.color(cards[j]) == 'red') red += 1;
                  }
                }
                var cards = player.getCards("h");
                var count = 0;
                for (var i = 0; i < cards.length; i++) {
                  if (get.color(cards[i]) == 'black' && black <= red) count += 1;
                  if (get.color(cards[i]) == 'red' && black >= red) count += 1;
                }
                if (cards.length - count <= count && count >= 1) return true;
                return false;
              },
              check: function(event, player) {
                var players = game.filterPlayer();
                var black = 0;
                var red = 0;
                for (var i = 0; i < players.length; i++) {
                  var cards = players[i].getCards("ej");
                  for (var j = 0; j < cards.length; j++) {
                    if (get.color(cards[j]) == 'black') black += 1;
                    if (get.color(cards[j]) == 'red') red += 1;
                  }
                }
                var cards = player.getCards("h");
                var count = 0;
                var value = 0;
                for (var i = 0; i < cards.length; i++) {
                  if (get.color(cards[i]) == 'black' && black <= red) {
                    value += get.value(cards[i]);
                    count += 1;
                  }
                  if (get.color(cards[i]) == 'red' && black >= red) {
                    value += get.value(cards[i]);
                    count += 1;
                  }
                }
                if (count == 0) return false;
                if (count == 1 && value < 5 && cards.length == 1 && player.hp <= 2) return true;
                if (count == 2 && value / (count + 0.0) < 5 && cards.length == 2) return true;
                if (count == 3 && value / (count + 0.0) < 7 && cards.length == 3) return true;
                if (count == 4 && value / (count + 0.0) < 7) return true;
                return false;
              },
              content: function() {
                player.awakenSkill('xingbian3d8');
                player.showHandcards();
                var xingbian3d8_cards = [];
                var players = game.filterPlayer();
                var black = 0;
                var red = 0;
                for (var i = 0; i < players.length; i++) {
                  var cards = players[i].getCards("ej");
                  for (var j = 0; j < cards.length; j++) {
                    if (get.color(cards[j]) == 'black') black += 1;
                    if (get.color(cards[j]) == 'red') red += 1;
                  }
                }
                var cards = player.getCards('h');
                for (var i = 0; i < cards.length; i++) {
                  if (get.color(cards[i]) == 'black' && black <= red) xingbian3d8_cards.push(cards[i]);
                  if (get.color(cards[i]) == 'red' && black >= red) xingbian3d8_cards.push(cards[i]);
                }
                player.lose(xingbian3d8_cards, ui.special, 'toStorage');
                player.storage.xingbian3d8.addArray(xingbian3d8_cards);
                player.markSkill('xingbian3d8');
                player.syncStorage('xingbian3d8');
                player.removeSkill('zhangchuan3d8');
                player.addSkill('huilan3d8');
                if (xingbian3d8_cards.length == cards.length) player.insertPhase();
              },
              intro: {
                content: "cards",
                onunmark: function(storage, player) {
                  if (storage && storage.length) {
                    player.$throw(storage, 1000);
                    game.cardsDiscard(storage);
                    game.log(storage, '被置入了弃牌堆');
                    storage.length = 0;
                  }
                },
              },
            },

            huilan3d8: {
              audio: "xingqi",
              enable: "phaseUse",
              filter: function(event, player) {
                return player.storage.xingbian3d8 && player.storage.xingbian3d8.length > 0;
              },
              chooseButton: {
                dialog: function(event, player) {
                  var list = ['wuzhong', 'sha'];
                  list[0] = ['trick', '', list[0]];
                  list[1] = ['basic', '', list[1]];
                  return ui.create.dialog('回澜', [list, 'vcard']);
                },
                filter: function(button, player) {
                  return lib.filter.filterCard({
                    name: button.link[2]
                  }, player, _status.event.getParent());
                },
                check: function(button) {
                  var player = _status.event.player;
                  var shaTarget = false;
                  for (var i = 0; i < game.players.length; i++) {
                    if (player.canUse('sha', game.players[i]) && ai.get.effect(game.players[i], {
                        name: 'sha'
                      }, player) > 0) {
                      shaTarget = true;
                    }
                  }
                  if (shaTarget && !player.num('h', 'sha')) return (button.link[2] == 'sha') ? 1 : -1;
                  return (button.link[2] == 'wuzhong') ? 1 : -1;
                },
                backup: function(links, player) {
                  return {
                    filterCard: function(card) {
                      return false;
                    },
                    selectCard: -1,
                    viewAs: {
                      name: links[0][2]
                    },
                    cards: links,
                    onuse: function(result, player) {
                      result.cards = player.storage.xingbian3d8.slice(0, 1);
                      var card = result.cards[0];
                      player.storage.xingbian3d8.remove(card);
                      game.cardsDiscard(card);
                      player.syncStorage('xingbian3d8');
                    }
                  }
                },
                prompt: function(links, player) {
                  return '将一张【星变】牌当' + get.translation(links[0][2]) + '使用';
                },
              },
              ai: {
                order: 8,
                result: {
                  player: 1,
                },
              },
              group: ["huilan3d8_respond", "huilan3d8_wuzhong", "huilan3d8_sha"],
              subSkill: {
                respond: {
                  enable: ["chooseToUse", "chooseToRespond"],
                  filterCard: function() {
                    return false;
                  },
                  selectCard: -1,
                  viewAs: {
                    name: "sha",
                  },
                  viewAsFilter: function(player) {
                    var event = _status.event;
                    if (event.parent && event.parent.name == 'phaseUse') return false;
                    return player.storage.xingbian3d8 && player.storage.xingbian3d8.length > 0;
                  },
                  prompt: "弃置一张【星变】牌，视为使用或打出一张杀",
                  check: function() {
                    return 1
                  },
                  onuse: function(result, player) {
                    result.cards = player.storage.xingbian3d8.slice(0, 1);
                    var card = result.cards[0];
                    player.storage.xingbian3d8.remove(card);
                    game.cardsDiscard(card);
                    player.syncStorage('xingbian3d8');
                  },
                  onrespond: function(result, player) {
                    result.cards = player.storage.xingbian3d8.slice(0, 1);
                    var card = result.cards[0];
                    player.storage.xingbian3d8.remove(card);
                    game.cardsDiscard(card);
                    player.syncStorage('xingbian3d8');
                  },
                  ai: {
                    skillTagFilter: function(player) {
                      return player.storage.xingbian3d8 && player.storage.xingbian3d8.length > 0;
                    },
                    respondSha: true,
                    basic: {
                      useful: [5, 1],
                      value: [5, 1],
                    },
                  }
                },
                wuzhong: {
                  trigger: {
                    player: "useCard",
                  },
                  direct: true,
                  filter: function(event, player) {
                    if (event.card.name != 'wuzhong') return false;
                    var players = game.filterPlayer();
                    for (var i = 0; i < players.length; i++) {
                      if (players[i] == player) continue;
                      if (event.skill && event.skill == 'huilan3d8_backup' && players[i].countCards("h") <= player.storage.xingbian3d8.length + 1) return true;
                      if (players[i].countCards("h") <= player.storage.xingbian3d8.length + 1) return true;
                    }
                    return false;
                  },
                  check: function(event, player) {
                    var players = game.filterPlayer();
                    for (var i = 0; i < players.length; i++) {
                      if (get.attitude(player, players[i]) > 2 && players[i].countCards('h') < player.countCards('h')) return true;
                    }
                    return false;
                  },
                  prompt: "是否对一名其他角色使用【无中生有】？",
                  content: function() {
                    "step 0"
                    player.chooseTarget(get.prompt('huilan3d8'), function(card, player, target) {
                      if (target == player) return false;
                      if (trigger.skill && trigger.skill == 'huilan3d8_backup') return target.countCards("h") <= player.storage.xingbian3d8.length + 1;
                      return target.countCards("h") <= player.storage.xingbian3d8.length;
                    }).ai = function(target) {
                      if (get.attitude(player, target) <= 2) return false;
                      return player.countCards('h') - target.countCards('h') + target.maxHp - target.hp;
                    }
                    "step 1"
                    if (result.bool) {
                      player.logSkill('huilan3d8');
                      trigger.cancel();
                      result.targets[0].draw(2);
                    }
                  },
                  ai: {
                    expose: 0.2,
                  },
                },
                sha: {
                  trigger: {
                    player: 'useCard1',
                  },
                  forced: true,
                  popup: false,
                  filter: function(event, player) {
                    if (!event.card || event.card.name != 'sha') return false;
                    if (!event.targets) return false;
                    var targets = event.targets;
                    if (!event.skill || event.skill != 'huilan3d8_backup') return false;
                    for (var i = 0; i < targets.length; i++) {
                      if (targets[i].countCards("h") <= player.storage.xingbian3d8.length) return true;
                    }
                    return false;
                  },
                  content: function() {
                    if (trigger.addCount !== false) {
                      trigger.addCount = false;
                      var stat = player.getStat().card;
                      if (stat.sha) stat.sha--;
                    }
                  },
                }
              }
            },

            langhuai3d8: {
              audio: "jlsg_zhejie",
              init: function(player) {
                player.storage.langhuai3d8 = 0;
              },
              trigger: {
                player: "phaseDrawBegin2",
              },
              filter: function(event, player) {
                return !event.numFixed;
              },
              check: function(event, player) {
                var num = 0;
                if (player.storage.langhuai3d8 == 0) {
                  var suits = [];
                  var cards = player.get('h');
                  for (var i = 0; i < cards.length; i++) {
                    if (!suits.contains(get.suit(cards[i])))
                      suits.add(get.suit(cards[i]));
                  }
                  num = suits.length;
                } else {
                  var suits = ['heart', 'club', 'spade', 'diamond'];
                  var cards = player.get('h');
                  for (var i = 0; i < cards.length; i++) {
                    if (suits.contains(get.suit(cards[i])))
                      suits.remove(get.suit(cards[i]));
                  }
                  num = suits.length;
                }
                if (num > 2) return true;
                else if (player.storage.langhuai3d8 == 0 && num == 2 && Math.random > 0.3) return true;
                else if (player.storage.langhuai3d8 == 1 && num == 2 && Math.random > 0.7) return true;
                return false;
              },
              prompt2: function(event, player) {
                var str = '是否改为摸手中';
                str += player.storage.langhuai3d8 == 0 ? '包含' : '缺少';
                str += '花色的牌数？';
                return str;
              },
              content: function() {
                player.showHandcards();
                if (player.storage.langhuai3d8 == 0) {
                  var suits = [];
                  event.cards = player.get('h');
                  for (var i = 0; i < event.cards.length; i++) {
                    if (!suits.contains(get.suit(event.cards[i])))
                      suits.add(get.suit(event.cards[i]));
                  }
                  trigger.num = suits.length;
                  player.storage.langhuai3d8 = 1;
                } else {
                  var suits = ['heart', 'club', 'spade', 'diamond'];
                  event.cards = player.get('h');
                  for (var i = 0; i < event.cards.length; i++) {
                    if (suits.contains(get.suit(event.cards[i])))
                      suits.remove(get.suit(event.cards[i]));
                  }
                  trigger.num = suits.length;
                  player.storage.langhuai3d8 = 0;
                }

              },
              ai: {
                threaten: 1.3,
              },
            },

            langhuai3d8_forced: {
              audio: "jlsg_zhejie",
              init: function(player) {
                player.storage.langhuai3d8 = 0;
              },
              trigger: {
                player: "phaseDrawBegin2",
              },
              forced: true,
              filter: function(event, player) {
                return !event.numFixed;
              },
              content: function() {
                player.showHandcards();
                if (player.storage.langhuai3d8 == 0) {
                  var suits = [];
                  event.cards = player.get('h');
                  for (var i = 0; i < event.cards.length; i++) {
                    if (!suits.contains(get.suit(event.cards[i])))
                      suits.add(get.suit(event.cards[i]));
                  }
                  trigger.num = suits.length;
                  player.storage.langhuai3d8 = 1;
                } else {
                  var suits = ['heart', 'club', 'spade', 'diamond'];
                  event.cards = player.get('h');
                  for (var i = 0; i < event.cards.length; i++) {
                    if (suits.contains(get.suit(event.cards[i])))
                      suits.remove(get.suit(event.cards[i]));
                  }
                  trigger.num = suits.length;
                  player.storage.langhuai3d8 = 0;
                }

              },
              ai: {
                threaten: 1.3,
              },
            },

            xuanlun3d8: {
              audio: "jlsg_fengya",
              init: function(player) {
                player.storage.xuanlun3d8 = 0;
              },
              trigger: {
                player: "damageEnd",
              },
              filter: function(event, player) {
                return true;
              },
              check: function(event, player) {
                return true;
              },
              content: function() {
                player.storage.xuanlun3d8 = 1;
                player.draw(4);
              },
              ai: {
                maixie: true,
                "maixie_hp": true,
                effect: {
                  target: function(card, player, target) {
                    if (player.hasSkillTag('jueqing', false, target)) return [1, -1];
                    if (get.tag(card, 'damage')) return [1, 0.55];
                  },
                },
              },
              group: ["xuanlun3d8_after"],
              subSkill: {
                after: {
                  audio: "jlsg_fengya",
                  trigger: {
                    global: "phaseAfter",
                  },
                  forced: true,
                  sub: true,
                  filter: function(event, player) {
                    return player.storage.xuanlun3d8 == 1;
                  },
                  content: function() {
                    'step 0'
                    player.storage.xuanlun3d8 = 0;
                    player.chooseControl('放牌', '修改技能', function(event, player) {
                      var cards = player.getCards("he");
                      var num = 0;
                      var count = 0;
                      for (var i = 0; i < cards.length; i++) {
                        var value = get.value(cards[i])
                        num += value;
                        if (value >= 8) count += 1;
                      }
                      var current = _status.currentPhase;
                      var enemy = 0;
                      current = current.next;
                      while (current != player) {
                        if (get.attitude(player, current) < 0) enemy += 1;
                        current = current.next;
                      }
                      //save own life
                      if (player.hp == 1 && player.countCards("he") <= 4 && enemy >= 1) return '修改技能';
                      //baofa
                      if (enemy == 0 && player.storage.langhuai3d8 == 0 && player.countCards("he") >= 4 && player.countCards("he") - count < 4) return '修改技能';
                      return '放牌';
                    }).set('prompt', '玄论：将四张牌以任意顺序置于牌堆底（不足则全置）；或令“朗怀”和“玄论”改为“锁定技”，然后删除该选项');
                    'step 1'
                    if (result.control) {
                      if (result.control == '放牌') {
                        event.goto(2);
                      } else {
                        player.removeSkill("langhuai3d8");
                        player.addSkill("langhuai3d8_forced");
                        player.removeSkill("xuanlun3d8");
                        player.addSkill("xuanlun3d8_forced");
                        event.finish();
                      }
                    } else event.finish();
                    'step 2'
                    var count = Math.min(4, player.countCards("he"));
                    player.chooseCard('he', true, [count, count], '将四张牌（不足则全置）置于牌堆底，先点击者在上').set('ai', function(card) {
                      var current = _status.currentPhase;
                      var enemy = 0;
                      current = current.next;
                      while (current != player) {
                        if (get.attitude(player, current) < 0) enemy += 1;
                        current = current.next;
                      }
                      if (enemy == 0) return 20 - get.value(card);
                      else if (enemy == 1) return 100 - (get.value(card) + get.useful(card));
                      return 20 - get.useful(card);
                    });
                    'step 3'
                    if (result.bool) {
                      event.cardss = result.cards.slice(0);
                      player.lose(event.cardss, ui.special);
                      player.$throw(event.cardss, 1000, 'nobroadcast');
                    }
                    'step 4'
                    for (var i = event.cardss.length - 1; i >= 0; i--) {
                      event.cardss[i].fix();
                      ui.cardPile.appendChild(event.cardss[i]);
                    }
                    game.log(player, '将', event.cardss.length, '张牌置于牌堆底');
                  },
                }
              }
            },

            xuanlun3d8_forced: {
              audio: "jlsg_fengya",
              init: function(player) {
                player.storage.xuanlun3d8 = 0;
              },
              trigger: {
                player: "damageEnd",
              },
              forced: true,
              filter: function(event, player) {
                return true;
              },
              content: function() {
                player.storage.xuanlun3d8 = 1;
                player.draw(4);
              },
              ai: {
                maixie: true,
                "maixie_hp": true,
                effect: {
                  target: function(card, player, target) {
                    if (player.hasSkillTag('jueqing', false, target)) return [1, -1];
                    if (get.tag(card, 'damage')) return [1, 0.55];
                  },
                },
              },
              group: ["xuanlun3d8_forced_after"],
              subSkill: {
                after: {
                  audio: "jlsg_fengya",
                  trigger: {
                    global: "phaseAfter",
                  },
                  forced: true,
                  sub: true,
                  filter: function(event, player) {
                    return player.storage.xuanlun3d8 == 1;
                  },
                  content: function() {
                    'step 0'
                    player.storage.xuanlun3d8 = 0;
                    var count = Math.min(4, player.countCards("he"));
                    player.chooseCard('he', true, [count, count], '将四张牌（不足则全置）置于牌堆底，先点击者在上').set('ai', function(card) {
                      return 20 - get.value(card);
                    });
                    'step 1'
                    if (result.bool) {

                      event.cardss = result.cards.slice(0);
                      player.lose(event.cardss, ui.special);
                      player.$throw(event.cardss, 1000, 'nobroadcast');
                    }
                    'step 2'
                    for (var i = event.cardss.length - 1; i >= 0; i--) {
                      event.cardss[i].fix();
                      ui.cardPile.appendChild(event.cardss[i]);
                    }
                    game.log(player, '将', event.cardss.length, '张牌置于牌堆底');
                  },
                }
              },

            },

            chouguo3d8: {
              audio: "zhiming",
              forced: true,
              trigger: {
                global: ["shaBefore"],
              },
              filter: function(event, player) {
                var players = game.filterPlayer();
                var count = Math.min();
                for (var i = 0; i < players.length; i++) {
                  count = Math.min(count, players[i].countCards("h"));
                }
                return count == player.countCards("h");
              },
              content: function() {
                "step 0"
                player.draw();
                "step 1"
                if (trigger.player == player) {
                  var count = Math.min();
                  var players = game.filterPlayer();
                  for (var i = 0; i < players.length; i++) {
                    count = Math.min(count, players[i].hp);
                  }
                  if (player.hp == count) {
                    trigger.cancel();
                    player.recover();
                  }
                }
              },
              ai: {
                expose: 0.3,
                effect: {
                  player: function(card, player, target, current) {
                    if (card.name != 'sha') return;
                    var players = game.filterPlayer();
                    var count = Math.min();
                    var hp = Math.min();
                    for (var i = 0; i < players.length; i++) {
                      count = Math.min(count, players[i].countCards("h"));
                      hp = Math.min(hp, players[i].hp);
                    }
                    if (player.hp == count && count == player.countCards("h") && player.hp == player.maxHp) return 'zeroplayertarget';
                  },
                },
              },
            },

            jianxiang3d8: {
              audio: "xingbu",
              group: ["jianxiang3d8_init", "jianxiang3d8_recover"],
              global: ["jianxiang3d8_remove1", "jianxiang3d8_remove2"],
              trigger: {
                player: "phaseAfter",
              },
              direct: true,
              filter: function(event, player) {
                return player.getHistory('useCard', function(card) {
                  return get.type(card.card, 'equip') == 'equip';
                }).length != 0 || player.storage.jianxiang3d8_recover == 1;
              },
              content: function() {
                "step 0"
                player.chooseTarget('选择【谏降】的目标', function(card, player, target) {
                  return target != player && (!target.hasSkill("duwu") || !target.hasSkill("chouguo3d8"));
                }).set('ai', function(target) {
                  if (get.attitude(player, target) <= 0) return -1;
                  else if (target.hp >= 3 && target.countCards("h") >= 3 && (!target.hasSkill("duwu")) && (!target.hasJudge('lebu'))) return 2;
                  else if (target.hp <= 2 && target.countCards("h") <= 2 && (!target.hasSkill("chouguo3d8"))) return 2.5;
                  else return 1;
                });
                "step 1"

                if (result.bool) {
                  var list = [];
                  var target = result.targets[0];
                  event.target = target;
                  game.log(player, "选择了", target);
                  player.line(result.targets, 'green');
                  if (!target.hasSkill("chouguo3d8")) list.push('仇国');
                  if (!target.hasSkill("duwu")) list.push('黩武');
                  target.chooseControl(list, true, function(event, player) {
                    var target = result.targets[0];
                    if (player.hasSkill("chouguo3d8")) return '黩武';
                    if (player.hasSkill("duwu")) return '仇国';
                    if (player.hp >= 3 && player.countCards("h") >= 3 && (!player.hasSkill("duwu")) && (!player.hasJudge('lebu'))) return '黩武';
                    if (player.hp <= 2 && player.countCards("h") <= 2 && (!player.hasSkill("chouguo3d8"))) return '仇国';
                    if (player.countCards("h") >= 3 && player.hp > 1) return '黩武';
                    return '仇国';
                  }).set('prompt', '谏降：令其视为拥有“仇国”直到你回合开始；视为拥有“黩武”直到其回合结束');
                }
                "step 2"
                if (result.control) {
                  if (result.control == '黩武') {
                    game.log(event.target, "选择了", '#g【' + get.translation('duwu') + '】');
                    event.target.addSkill('duwu');
                    event.target.storage.jianxiang3d8_remove2 = 1;
                  }
                  if (result.control == '仇国') {
                    game.log(event.target, "选择了", '#g【' + get.translation('chouguo3d8') + '】');
                    event.target.addSkill('chouguo3d8');
                    event.target.storage.jianxiang3d8_remove1_source = player;
                    event.target.storage.jianxiang3d8_remove1 = 1;
                  }

                }
              },
              subSkill: {
                init: {
                  trigger: {
                    global: "gameStart",
                    player: "phaseBefore",
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    player.storage.jianxiang3d8_recover = 0;
                  },
                  sub: true,
                },


                recover: {
                  trigger: {
                    player: "recoverAfter",
                  },
                  forced: true,
                  popup: false,
                  filter: function(event, player) {
                    return true;
                  },
                  content: function() {
                    player.storage.jianxiang3d8_recover = 1;
                  },
                  sub: true,
                },
              },

              ai: {
                expose: 0.5,
                threaten: 0.8,
              },
            },

            jianxiang3d8_remove1: {
              init: function(player) {
                player.storage.jianxiang3d8_remove1_source = 0;
                player.storage.jianxiang3d8_remove1 = 0;
              },
              trigger: {
                global: "phaseBefore",
              },
              forced: true,
              popup: false,
              filter: function(event, player) {
                if (player.storage.jianxiang3d8_remove1_source == 0) return false;
                return event.player == player.storage.jianxiang3d8_remove1_source && player.storage.jianxiang3d8_remove1 == 1;
              },
              content: function() {
                player.removeSkill('chouguo3d8');
                player.storage.jianxiang3d8_remove1_source = 0;
                player.storage.jianxiang3d8_remove1 = 0;
              },
            },

            jianxiang3d8_remove2: {
              init: function(player) {
                player.storage.jianxiang3d8_remove2 = 0;
              },
              trigger: {
                player: "phaseAfter",
              },
              forced: true,
              popup: false,
              filter: function(event, player) {
                return player.storage.jianxiang3d8_remove2 == 1;
              },
              content: function() {
                player.removeSkill('duwu');
                player.storage.jianxiang3d8_remove2 = 0;
              },
            },

            huili3d8: {
              group: ["huili3d8_1", "huili3d8_2", "huili3d8_3"],
              audio: "qinzheng",
              forced: true,
              trigger: {
                global: "roundStart",
              },
              content: function() {
                if (!player.hasMark("huili3d8_min")) player.addMark("huili3d8_min");
                if (!player.hasMark("huili3d8_zheng")) player.addMark("huili3d8_zheng");
                if (!player.hasMark("huili3d8_jun")) player.addMark("huili3d8_jun");
              },
              subSkill: {
                "1": {
                  sub: true,
                  audio: "qinzheng",
                  forced: true,
                  trigger: {
                    target: "useCardToTargeted",
                  },
                  filter: function(event, player) {
                    return get.type(event.card) == 'basic' && player.hasMark("huili3d8_min");
                  },
                  content: function() {
                    "step 0"
                    player.removeMark("huili3d8_min");
                    "step 1"
                    player.chooseTarget('惠理：令一名角色摸一张牌').set('ai', function(target) {
                      if (get.attitude(player, target) <= 0) return -1;
                      return Math.max(1, 4 - target.countCards("h"));
                    });
                    "step 2"
                    if (result.bool) {
                      player.logSkill('huili3d8', result.targets);
                      result.targets[0].draw();
                    }
                  },
                },
                "2": {
                  sub: true,
                  audio: "qinzheng",
                  forced: true,
                  trigger: {
                    target: "useCardToTargeted",
                  },
                  filter: function(event, player) {
                    return (get.type(event.card) == 'trick' || get.type(event.card) == 'delay') && player.hasMark("huili3d8_zheng");
                  },
                  content: function() {
                    "step 0"
                    player.removeMark("huili3d8_zheng");
                    "step 1"
                    player.chooseTarget('惠理：令一名角色摸一张牌').set('ai', function(target) {
                      if (get.attitude(player, target) <= 0) return -1;
                      return Math.max(1, 4 - target.countCards("h"));
                    });
                    "step 2"
                    if (result.bool) {
                      player.logSkill('huili3d8', result.targets);
                      result.targets[0].draw();
                    }
                  },
                },
                "3": {
                  sub: true,
                  audio: "qinzheng",
                  forced: true,
                  trigger: {
                    target: "useCardToTargeted",
                  },
                  filter: function(event, player) {
                    return get.type(event.card) == 'equip' && player.hasMark("huili3d8_jun");
                  },
                  content: function() {
                    "step 0"
                    player.removeMark("huili3d8_jun");
                    "step 1"
                    player.chooseTarget('惠理：令一名角色摸一张牌').set('ai', function(target) {
                      if (get.attitude(player, target) <= 0) return -1;
                      return Math.max(1, 4 - target.countCards("h"));
                    });
                    "step 2"
                    if (result.bool) {
                      player.logSkill('huili3d8', result.targets);
                      result.targets[0].draw();
                    }
                  },
                },
                min: {
                  sub: true,
                  mark: true,
                  marktext: "民",
                  intro: {
                    name: "民",
                    content: "mark",
                  },
                },
                zheng: {
                  sub: true,
                  mark: true,
                  marktext: "政",
                  intro: {
                    name: "政",
                    content: "mark",
                  },
                },
                jun: {
                  sub: true,
                  mark: true,
                  marktext: "军",
                  intro: {
                    name: "军",
                    content: "mark",
                  },
                },
              },
            },

            zhishu3d8: {
              audio: "qinzheng",
              enable: "phaseUse",
              filter: function(event, player) {
                return (player.hasMark("huili3d8_min") ||
                  player.hasMark("huili3d8_zheng") ||
                  player.hasMark("huili3d8_jun")) && !player.hasSkill("zhishu3d82");
              },
              filterTarget: function(card, player, target) {
                return target != player && target.countCards('h') > 0;
              },
              content: function() {
                "step 0"
                var controls = [];
                if (player.hasMark("huili3d8_min")) {
                  controls.push("基本牌");
                }
                if (player.hasMark("huili3d8_zheng")) {
                  controls.push("锦囊牌");
                }
                if (player.hasMark("huili3d8_jun")) {
                  controls.push("装备牌");
                }
                player.chooseControl(controls);
                "step 1"
                event.control = result.control;
                switch (event.control) {
                  case '基本牌':
                    event.goto(2);
                    break;
                  case '锦囊牌':
                    event.goto(5);
                    break;
                  case '装备牌':
                    event.goto(8);
                    break;
                }
                "step 2"
                target.chooseToUse(function(card) {
                  if (!lib.filter.cardEnabled(card, _status.event.player, _status.event)) {
                    return false;
                  }
                  var type = get.type(card, 'trick');
                  return type == 'basic';
                }, '是否使用一张基本牌？');
                "step 3"
                if (result.bool) {
                  target.recover();
                  event.goto(11);
                } else {
                  player.chooseToUse(function(card) {
                    if (!lib.filter.cardEnabled(card, _status.event.player, _status.event)) {
                      return false;
                    }
                    var type = get.type(card, 'trick');
                    return type == 'basic';
                  }, '是否使用一张基本牌？');

                }
                "step 4"
                if (!result.bool) {
                  player.addTempSkill("zhishu3d82");
                  event.finish();
                } else {
                  event.finish();
                }

                "step 5"
                target.chooseToUse(function(card) {
                  if (!lib.filter.cardEnabled(card, _status.event.player, _status.event)) {
                    return false;
                  }
                  var type = get.type(card, 'trick');
                  return type == 'trick' || type == 'delay';
                }, '是否使用一张锦囊牌？');
                "step 6"
                if (result.bool) {
                  target.recover();
                  player.removeMark("huili3d8_zheng");
                  event.goto(13);
                } else {
                  player.chooseToUse(function(card) {
                    if (!lib.filter.cardEnabled(card, _status.event.player, _status.event)) {
                      return false;
                    }
                    var type = get.type(card, 'trick');
                    return type == 'trick' || type == 'delay';
                  }, '是否使用一张锦囊牌？');

                }
                "step 7"
                if (!result.bool) {
                  player.addTempSkill("zhishu3d82");
                  event.finish();
                } else {
                  event.finish();
                }

                "step 8"
                target.chooseToUse(function(card) {
                  if (!lib.filter.cardEnabled(card, _status.event.player, _status.event)) {
                    return false;
                  }
                  var type = get.type(card, 'trick');
                  return type == 'equip';
                }, '是否使用一张装备牌？');
                "step 9"
                if (result.bool) {
                  target.recover();
                  player.removeMark("huili3d8_jun");
                  event.goto(15);
                } else {
                  player.chooseToUse(function(card) {
                    if (!lib.filter.cardEnabled(card, _status.event.player, _status.event)) {
                      return false;
                    }
                    var type = get.type(card, 'trick');
                    return type == 'equip';
                  }, '是否使用一张装备牌？');
                }
                "step 10"
                if (!result.bool) {
                  player.addTempSkill("zhishu3d82");
                  event.finish();
                } else {
                  event.finish();
                }
                "step 11"
                if (player.hasMark("huili3d8_min")) {
                  player.removeMark("huili3d8_min");
                  player.chooseTarget('惠理：令一名角色摸一张牌').set('ai', function(target) {
                    if (get.attitude(player, target) <= 0) return -1;
                    return Math.max(1, 4 - target.countCards("h"));
                  });
                }
                "step 12"
                if (result.bool) {
                  player.logSkill('huili3d8', result.targets);
                  result.targets[0].draw();
                  event.finish();
                }
                "step 13"
                if (player.hasMark("huili3d8_zheng")) {
                  player.removeMark("huili3d8_zheng");
                  player.chooseTarget('惠理：令一名角色摸一张牌').set('ai', function(target) {
                    if (get.attitude(player, target) <= 0) return -1;
                    return Math.max(1, 4 - target.countCards("h"));
                  });
                }
                "step 14"
                if (result.bool) {
                  player.logSkill('huili3d8', result.targets);
                  result.targets[0].draw();
                  event.finish();
                }
                "step 15"
                if (player.hasMark("huili3d8_jun")) {
                  player.removeMark("huili3d8_jun");
                  player.chooseTarget('惠理：令一名角色摸一张牌').set('ai', function(target) {
                    if (get.attitude(player, target) <= 0) return -1;
                    return Math.max(1, 4 - target.countCards("h"));
                  });
                }
                "step 16"
                if (result.bool) {
                  player.logSkill('huili3d8', result.targets);
                  result.targets[0].draw();
                  event.finish();
                }
              },
              ai: {
                order: 9,
                result: {
                  target: function(player, target) {
                    if (target.hp <= 2) return 5;
                    if (target.countCards('h') > target.hp) return 5;
                    return 2;
                  },
                },
                threaten: 2,
              },
            },
            "zhishu3d82": {},

            kuangnan3d8: {
              trigger: {
                global: "phaseBegin",
              },
              direct: true,
              filter: function(event, player) {
                return !player.hasSkill("kuangnan3d82") && game.hasPlayer(function(current) {
                  return event.player.inRange(current) && current.hp < current.maxHp;
                });
              },
              content: function() {
                "step 0"
                player.chooseTarget(get.prompt("kuangnan3d8"), "令一名角色回复1点体力", function(card, player, target) {
                  return target.hp < target.maxHp && trigger.player.inRange(target);
                }).set("ai", function(target) {
                  var player = _status.event.player;
                  return get.recoverEffect(target, player, player);
                });
                "step 1"
                if (result.bool) {
                  var target = result.targets[0];
                  player.logSkill("kuangnan3d8", target);
                  var num = 1;
                  if (player.storage.bianwang3d8 == true) num++;
                  target.recover(num);
                  player.addSkill("kuangnan3d82");
                  player.storage.kuangnan3d8_target = trigger.player;
                  player.storage.kuangnan3d8_source = target;
                }
              }
            },
            kuangnan3d82: {
              mark: true,
              marktext: "匡",
              intro: {
                content: "不能发动“匡难”",
              },
              trigger: {
                global: "damageBegin3"
              },
              forced: true,
              popup: false,
              charlotte: true,
              filter: function(event, player) {
                if (player.storage.kuangnan3d8_target && event.player == player.storage.kuangnan3d8_target) return true;
                if (player.storage.kuangnan3d8_source && event.source == player.storage.kuangnan3d8_source) return true;
                return false;
              },
              content: function() {
                "step 0"
                player.removeSkill("kuangnan3d82");
                delete player.storage.kuangnan3d8_target;
                delete player.storage.kuangnan3d8_source;
                "step 1"
                if (player.storage.bianwang3d8 != true) trigger.num++;
              }
            },
            bianwang3d8: {
              locked: false,
              zhuanhuanji: true,
              mark: true,
              marktext: "辩",
              intro: {
                content: function(storage, player, skill) {
                  if (player.storage.bianwang3d8 == true) return "一回合限一次，一名角色回复体力前，你可以令之于本回合结束时结算，若此时已无法执行，你能令另一名角色结算之";
                  return "一回合限一次，一名角色受到伤害或失去体力前，你可以令之于本回合结束时结算，若此时已无法执行，你能令另一名角色结算之";
                }
              },
              group: ["bianwang3d8_damage", "bianwang3d8_recover", "bianwang3d8_after", "bianwang3d8_die"],
              subSkill: {
                damage: {
                  trigger: {
                    global: ["damageBegin4", "loseHpBegin"]
                  },
                  filter: function(event, player) {
                    if (player.hasSkill("bianwang3d82")) return false;
                    if (event.num == 0) return false;
                    return player.storage.bianwang3d8 != true;
                  },
                  check: function(event, player) {
                    var target = event.player;
                    if (get.attitude(player, target) <= 0) return false;
                    return true;
                  },
                  logTarget: "player",
                  content: function() {
                    "step 0"
                    player.storage.bianwang3d8 = true;
                    player.addTempSkill("bianwang3d82");
                    "step 1"
                    if (event.triggername == "damageBegin4") {
                      player.storage.bianwang3d8_damage = true;
                      if (trigger.source) player.storage.bianwang3d8_source = trigger.source;
                      if (trigger.nature) player.storage.bianwang3d8_nature = trigger.nature;
                      player.storage.bianwang3d8_damagetarget = trigger.player;
                      player.storage.bianwang3d8_num = trigger.num;
                    } else {
                      player.storage.bianwang3d8_loseHp = true;
                      player.storage.bianwang3d8_losehptarget = trigger.player;
                      player.storage.bianwang3d8_num = trigger.num;
                    }
                    "step 2"
                    trigger.cancel();
                  }
                },
                recover: {
                  trigger: {
                    global: "recoverBefore",
                  },
                  filter: function(event, player) {
                    if (player.hasSkill("bianwang3d82")) return false;
                    if (event.num == 0) return false;
                    return player.storage.bianwang3d8 == true;
                  },
                  check: function(event, player) {
                    var target = event.player;
                    if (get.attitude(player, target) >= 0) return false;
                    return true;
                  },
                  logTarget: "player",
                  content: function() {
                    "step 0"
                    player.storage.bianwang3d8 = false;
                    player.storage.bianwang3d8_recover = true;
                    player.addTempSkill("bianwang3d82");
                    "step 1"
                    player.storage.bianwang3d8_recovertarget = trigger.player;
                    player.storage.bianwang3d8_num = trigger.num;
                    "step 2"
                    trigger.cancel();
                  }
                },
                after: {
                  trigger: {
                    global: "phaseEnd"
                  },
                  filter: function(event, player) {
                    if (player.storage.bianwang3d8_damage == true) return true;
                    if (player.storage.bianwang3d8_loseHp == true) return true;
                    if (player.storage.bianwang3d8_recover == true) return true;
                    return false;
                  },
                  forced: true,
                  content: function() {
                    "step 0"
                    if (player.storage.bianwang3d8_damage == true || player.storage.bianwang3d8_loseHp == true) {
                      if (player.storage.bianwang3d8_source && player.storage.bianwang3d8_damagetarget) {
                        var source = player.storage.bianwang3d8_source;
                        var target = player.storage.bianwang3d8_damagetarget;
                        var num = player.storage.bianwang3d8_num;
                        if (player.storage.bianwang3d8_nature) var nature = player.storage.bianwang3d8_nature;
                        target.damage(num, nature, source);
                      }
                      if (!player.storage.bianwang3d8_source && player.storage.bianwang3d8_damagetarget) {
                        var target = player.storage.bianwang3d8_damagetarget;
                        var num = player.storage.bianwang3d8_num;
                        if (player.storage.bianwang3d8_nature) var nature = player.storage.bianwang3d8_nature;
                        target.damage(num, nature, "nosource");
                      }
                      if (player.storage.bianwang3d8_losehptarget) {
                        var target = player.storage.bianwang3d8_losehptarget;
                        var num = player.storage.bianwang3d8_num;
                        target.loseHp(num);
                      }
                      if (!player.storage.bianwang3d8_damagetarget && player.storage.bianwang3d8_damage == true) {
                        player.chooseTarget(get.prompt("bianwang3d8"), "令另一名角色结算此次伤害", function(card, player, target) {
                          return true;
                        }).set("ai", function(target) {
                          var player = _status.event.player;
                          return get.damageEffect(target, player, player);
                        });
                        event.goto(1);
                      }
                      if (!player.storage.bianwang3d8_losehptarget && player.storage.bianwang3d8_loseHp == true) {
                        player.chooseTarget(get.prompt("bianwang3d8"), "令另一名角色结算此次失去体力", function(card, player, target) {
                          return true;
                        }).set("ai", function(target) {
                          var player = _status.event.player;
                          return get.damageEffect(target, player, player);
                        });
                        event.goto(2);
                      }
                    }
                    if (player.storage.bianwang3d8_recover == true) {
                      if (player.storage.bianwang3d8_recovertarget && player.storage.bianwang3d8_recovertarget.isDamaged()) {
                        var target = player.storage.bianwang3d8_recovertarget;
                        var num = player.storage.bianwang3d8_num;
                        target.recover(num);
                      }
                      if (!player.storage.bianwang3d8_recovertarget || player.storage.bianwang3d8_recovertarget.isHealthy()) {
                        player.chooseTarget(get.prompt("bianwang3d8"), "令另一名角色结算此次回复体力", function(card, player, target) {
                          return target.isDamaged();
                        }).set("ai", function(target) {
                          var player = _status.event.player;
                          return get.recoverEffect(target, player, player);
                        });
                        event.goto(3);
                      }
                    }
                    "step 1"
                    if (result.bool) {
                      var target = result.targets[0];
                      player.line(target);
                      var num = player.storage.bianwang3d8_num;
                      if (player.storage.bianwang3d8_nature) var nature = player.storage.bianwang3d8_nature;
                      if (player.storage.bianwang3d8_source) target.damage(num, nature, player.storage.bianwang3d8_source);
                      else target.damage(num, nature, "nosource");
                    }
                    event.goto(4);
                    "step 2"
                    if (result.bool) {
                      var target = result.targets[0];
                      player.line(target);
                      var num = player.storage.bianwang3d8_num;
                      target.loseHp(num);
                    }
                    event.goto(4);
                    "step 3"
                    if (result.bool) {
                      var target = result.targets[0];
                      player.line(target);
                      var num = player.storage.bianwang3d8_num;
                      target.recover(num);
                    }
                    event.goto(4);
                    "step 4"
                    delete player.storage.bianwang3d8_damage;
                    delete player.storage.bianwang3d8_source;
                    delete player.storage.bianwang3d8_nature;
                    delete player.storage.bianwang3d8_damagetarget;
                    delete player.storage.bianwang3d8_num;
                    delete player.storage.bianwang3d8_loseHp;
                    delete player.storage.bianwang3d8_losehptarget;
                    delete player.storage.bianwang3d8_recover;
                    delete player.storage.bianwang3d8_recovertarget;
                  }
                },
                die: {
                  trigger: {
                    global: "dieAfter"
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    if (player.storage.bianwang3d8_source == trigger.player) delete player.storage.bianwang3d8_source;
                    if (player.storage.bianwang3d8_damagetarget == trigger.player) delete player.storage.bianwang3d8_damagetarget;
                    if (player.storage.bianwang3d8_losehptarget == trigger.player) delete player.storage.bianwang3d8_losehptarget;
                    if (player.storage.bianwang3d8_recovertarget == trigger.player) delete player.storage.bianwang3d8_recovertarget;
                  }
                }
              }
            },
            bianwang3d82: {},


            quhan3d8: {
              audio: "qingnang",
              enable: "phaseUse",
              filter: function(event, player) {
                if (!player.countCards('he')) return false;
                if (player.hasSkill('quhan3d82')) return false;
                return game.hasPlayer(function(current) {
                  return current != player && current.countCards('h') > 0 && current.hp < current.maxHp;
                });
              },
              filterTarget: function(card, player, target) {
                return target != player && target.hp < target.maxHp && target.countCards('h') > 0;
              },
              content: function() {
                'step 0'
                player.choosePlayerCard(target, 'h', Math.min(target.countCards('h'), target.maxHp - target.hp), true);
                'step 1'
                var hs = result.cards;
                target.showCards(hs);
                player.chooseCard({
                  filterCard: function(card) {
                    var suits = [];
                    for (var i = 0; i < result.cards.length; i++) {
                      suits.add(get.suit(result.cards[i]));
                    }
                    return suits.contains(get.suit(card));
                  },
                  position: 'he',
                  selectCard: 1,
                  ai: function(card) {
                    if (card.name == 'du' && player.hp == 1) return 1;
                    return 8 - get.value(card);
                  },
                  prompt: '弃置一张同花色的手牌，令' + get.translation(target) + '回复一点体力'
                });
                'step 2'
                if (result.bool) {
                  player.discard(result.cards);
                  target.recover();
                } else {
                  player.addTempSkill("quhan3d82");
                }
              },
              ai: {
                order: 9,
                result: {
                  target: function(player, target) {
                    if (target.hp == 1) return 5;
                    return Math.min(target.maxHp - target.hp, target.countCards('h')) + 2;
                  },
                },
                threaten: 2,
              },
            },

            quhan3d82: {

            },

            changtang3d8: {
              audio: "jijiu",
              trigger: {
                player: "phaseJieshuBegin",
              },
              filter: function(event, player) {
                return true;
              },
              check: function(event, player) {
                var suits = [];
                var cards = player.getCards("h");
                for (var i = 0; i < cards.length; i++) {
                  suits.add(get.suit(cards[i]));
                }
                if (suits.length < 4) return true;
                return false;
              },
              content: function() {
                'step 0'
                player.chooseTarget(true, "选择一名除你之外手牌数最少的角色", function(card, player, target) {
                  if (player == target) return false;
                  var players = game.filterPlayer();
                  var min = Infinity;
                  for (var i = 0; i < players.length; i++) {
                    if (players[i] == player) continue;
                    min = Math.min(min, players[i].countCards("h"));
                  }
                  if (target.countCards("h") == min) return true;
                  return false;
                }, false).ai = function(target) {
                  return get.attitude(player, target) + 20
                };
                'step 1'
                player.showHandcards();
                event.target = result.targets[0];
                var players = [];
                var current = event.target.next;
                players.push(event.target);
                while (current != event.target) {
                  if (current != player) players.push(current);
                  current = current.next;
                }
                event.changtang3d8_curr = 0;
                event.changtang3d8_players = players;
                player.line(result.targets, 'green');
                'step 2'
                console.log(event.changtang3d8_players);
                event.changtang3d8_players[event.changtang3d8_curr].chooseCard({
                  filterCard: function(card) {
                    var suits = [];
                    var cards = trigger.player.getCards("h");
                    for (var i = 0; i < cards.length; i++) {
                      suits.add(get.suit(cards[i]));
                    }
                    return !suits.contains(get.suit(card));
                  },
                  position: 'he',
                  selectCard: 1,
                  ai: function(card) {
                    if (get.attitude(event.target, player) > 0) {
                      if (card.name == 'du') return 0.1;
                      return 20 - get.value(card);
                    }
                    if (card.name == 'du') return 20;
                    return 6 - get.value(card);
                  },
                  prompt: '交给' + get.translation(trigger.player) + '一张与其手牌花色均不同的牌'
                });
                "step 3"
                if (result.bool) {
                  trigger.player.gain(result.cards, event.changtang3d8_players[event.changtang3d8_curr], 'give');
                  event.changtang3d8_players[event.changtang3d8_curr].draw(2);
                } else game.log(event.changtang3d8_players[event.changtang3d8_curr], "没有交给", trigger.player, "牌");
                event.changtang3d8_curr += 1;
                if (event.changtang3d8_curr == event.changtang3d8_players.length) event.finish();
                else event.goto(2);

              },
              ai: {
                expose: 0.2,
                threaten: 0.8,
              },
            },

            jinggou3d8: {
              audio: "jlsg_zhige",
              forced: true,
              trigger: {
                player: 'useCardAfter',
              },
              filter: function(event, player) {
                if (get.type(event.card) != 'equip') return false;
                if (get.subtype(event.card) != 'equip1') return false;
                var max = Math.max();
                var min = Math.min();
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  max = Math.max(players[i].getAttackRange(), max);
                  min = Math.min(players[i].getAttackRange(), min);
                }
                if (player.getAttackRange() == max || player.getAttackRange() == min) return true;
                return false;
              },
              content: function() {
                'step 0'
                player.chooseTarget('精彀：对一名角色造成1点伤害', true, function(card, player, target) {
                  return true;
                }).ai = function(target) {
                  return get.damageEffect(target, player, player) + 10;
                }
                'step 1'
                if (result.bool) {
                  result.targets[0].damage(1);
                }
              },
              ai: {
                expose: 0.5,
                threaten: 1.5,
              },
            },

            moyan3d8: {
              global: ["moyan3d8_buff", "moyan3d8_init"],
              trigger: {
                global: "roundStart",
              },
              filter: function(event, player) {
                return true;
              },
              content: function() {
                "step 0"
                event.cards = get.cards(3);
                game.cardsGotoOrdering(event.cards);
                player.showCards(event.cards);
                player.chooseTarget("末焱：令一名角色获得至少一张牌", true, function(card, player, target) {
                  return true;
                }).ai = function(target) {
                  var cards = event.cards;
                  var value = 0;
                  var good = 0;
                  var bad = 0;
                  var rubbish = 0;
                  for (var i = 0; i < cards.length; i++) {
                    var val = get.value(cards[i]);
                    value += val;
                    if (val >= 7) good += 1;
                    if (val < 4) bad += 1;
                    if (val < 0) rubbish += 1;
                  }
                  if (good >= 1 || value >= 8) {
                    var att = get.attitude(player, target);
                    if (att > 0) {
                      return att * (1 + target.countCards("h"));
                    } else {
                      return att / 100;
                    }
                  }
                  return -get.attitude(player, target) / (1 + target.countCards("h"));
                }
                "step 1"
                if (result.bool) {
                  player.line(result.targets[0], "red");
                  var target = result.targets[0];
                  event.target = target;
                  target.chooseCardButton("选择并获得至少一张“末焱”牌", true, event.cards, [1, event.cards.length]).set("ai", function(button) {
                    if (get.value(button.link) >= 6) return 1;
                    return 0;
                  });
                }
                "step 2"
                if (result.bool) {
                  event.cards.remove(result.links);
                  event.target.gain(result.links, "gain2");
                  game.log(event.target, "通过“末焱”获得了" + get.cnNumber(result.links.length) + "张牌");
                  event.target.storage.moyan3d8_buff = result.links.length;
                  event.target.markSkill("moyan3d8_buff");
                }
              },
              subSkill: {
                buff: {
                  trigger: {
                    player: "damageBegin3",
                  },
                  marktext: "焱",
                  intro: {
                    content: "手牌数不大于#则受到的伤害+#",
                  },
                  popup: false,
                  filter: function(event, player) {
                    if ((!player.storage.moyan3d8_buff) || player.storage.moyan3d8_buff == 0) return false;
                    else if (player.countCards("h") > player.storage.moyan3d8_buff) return false;
                    return true;
                  },
                  forced: true,
                  content: function() {
                    trigger.num += player.storage.moyan3d8_buff;
                  },
                  sub: true,
                },
                init: {
                  trigger: {
                    global: ["gameStart", "roundStart"],
                  },
                  forced: true,
                  popup: false,
                  firstDo: true,
                  content: function() {
                    player.storage.moyan3d8_buff = 0;
                    player.unmarkSkill("moyan3d8_buff");
                  },
                  sub: true,
                },
              },
              ai: {
                expose: 0.5,
                threaten: 1.2,
              },
            },

            yijue3d8: {
              trigger: {
                player: "phaseBegin"
              },
              forced: true,
              content: function() {
                "step 0"
                var num = player.hp;
                event.cards = get.cards(num);
                game.cardsGotoOrdering(event.cards);
                player.showCards(event.cards);
                "step 1"
                player.chooseCardButton("请选择使用一张牌", event.cards).set("filterButton", function(button) {
                  var bool = game.hasPlayer(function(current) {
                    return player.canUse(button.link, current);
                  });
                  if (bool) return true;
                  return false;
                }).set("ai", function(button) {
                  return 1;
                });
                "step 2"
                if (result.bool) {
                  player.chooseUseTarget(result.links[0], true, false);
                  event.cards.remove(result.links[0]);
                } else event.goto(7);
                "step 3"
                if (event.current == undefined) event.current = player;
                event.list = result.targets;
                "step 4"
                if (!event.list.length) event.goto(6);
                if (event.list.contains(event.current) && event.cards.length) {
                  event.current.chooseCardButton("选择并获得一张“疑决”牌", true, event.cards).set("ai", function(button) {
                    if (get.value(button.link) >= 6) return 1;
                    return 0;
                  });
                }
                if (!event.list.contains(event.current)) {
                  event.current = event.current.next;
                  event.redo();
                }
                if (!event.cards.length) event.finish();
                "step 5"
                if (result.bool) {
                  event.cards.remove(result.links);
                  event.current.gain(result.links, "gain2");
                  event.list.remove(event.current);
                  if (event.list.length) {
                    event.goto(4);
                  }
                }
                "step 6"
                if (event.cards.length) event.goto(1);
                "step 7"
                if (event.cards.length) player.loseHp();
              }
            },

            yuanzhen3d8: {
              audio: "junxing",
              trigger: {
                player: "useCardToPlayered",
              },
              logTarget: "target",
              forced: true,
              filter: function(event, player) {
                if (event.targets.length > 1) return false;
                return get.distance(player, event.target) > 1;
              },
              check: function(event, player) {
                if (get.attitude(player, event.target) > 0) return true;
                var target = event.target;
                return target.countCards("h") == 0 || !target.hasSkillTag("noh");
              },
              content: function() {
                "step 0"
                trigger.target.chooseToDiscard("he", "弃置一张牌，或令" + get.translation(player) + "摸一张牌").set("ai", function(card) {
                  var trigger = _status.event.getTrigger();
                  return -get.attitude(trigger.target, trigger.player) - get.value(card);
                });
                "step 1"
                if (result.bool == false) player.draw();
              },
              effect: {
                player: function(card, player, target, current) {
                  if (get.tag(card, 'multitarget')) {
                    if ((card.name == 'nanman' || card.name == 'wanjian') && game.filterPlayer().length == 2) return [1, 1];
                    return;
                  }
                  if (get.distance(player, event.target) <= 1) return;
                  return [1, 1];
                },
              },
            },

            zhirong3d8: {
              audio: "yuce",
              trigger: {
                player: "phaseUseBegin",
              },
              filter: function(event, player) {
                var players = game.filterPlayer();
                var check = game.hasPlayer(function(current) {
                  if (current.countCards("e") == 0) return false;
                  var cards = current.getCards("e");
                  for (var i = 0; i < cards.length; i++) {
                    var card = cards[i];
                    for (var j = 0; j < players.length; j++) {
                      if (players[i] == current) continue;
                      if (!current.canUse({
                          name: "guohe",
                          isCard: true
                        }, players[i], false)) continue;
                      if (get.subtype(card) == 'equip1' && !players[i].isDisabled(1)) return true;
                      if (get.subtype(card) == 'equip2' && !players[i].isDisabled(2)) return true;
                      if (get.subtype(card) == 'equip3' && !players[i].isDisabled(3)) return true;
                      if (get.subtype(card) == 'equip4' && !players[i].isDisabled(4)) return true;
                      if (get.subtype(card) == 'equip5' && !players[i].isDisabled(5)) return true;
                    }
                  }
                  return false;
                });
                return check;
              },
              direct: true,
              content: function() {
                "step 0"
                var next = player.chooseTarget(2, function(card, player, target) {
                  if (ui.selected.targets.length) {
                    var current = ui.selected.targets[0];
                    if (!ui.selected.targets[0].canUse({
                        name: "guohe",
                        isCard: true
                      }, target, false)) return false;
                    var cards = current.getCards("e");
                    for (var i = 0; i < cards.length; i++) {
                      var card = cards[i];
                      if (get.subtype(card) == 'equip1' && !target.isDisabled(1)) return true;
                      if (get.subtype(card) == 'equip2' && !target.isDisabled(2)) return true;
                      if (get.subtype(card) == 'equip3' && !target.isDisabled(3)) return true;
                      if (get.subtype(card) == 'equip4' && !target.isDisabled(4)) return true;
                      if (get.subtype(card) == 'equip5' && !target.isDisabled(5)) return true;
                    }
                    return false;
                  } else {
                    return target.countCards("e") > 0 && game.hasPlayer(function(current) {
                      return target.canUse({
                        name: "guohe",
                        isCard: true
                      }, current, false);
                    });
                  }
                });
                next.set("ai", function(target) {
                  var player = _status.event.player;
                  var att = get.attitude(player, target);
                  var sgnatt = get.sgn(att);
                  var players = game.filterPlayer();
                  if (ui.selected.targets.length == 0) {
                    var cards = target.getCards("e");
                    var max = -1000;
                    for (var i = 0; i < players.length; i++) {
                      if (players[i] == target) continue;
                      if (!target.canUse({
                          name: "guohe",
                          isCard: true
                        }, players[i], false)) continue;
                      var val = get.effect(players[i], {
                        name: 'guohe'
                      }, target, player);
                      for (var j = 0; j < cards.length; j++) {
                        var card = cards[j];
                        if (get.subtype(card) == 'equip1' && players[i].isDisabled(1)) continue;
                        if (get.subtype(card) == 'equip2' && players[i].isDisabled(2)) continue;
                        if (get.subtype(card) == 'equip3' && players[i].isDisabled(3)) continue;
                        if (get.subtype(card) == 'equip4' && players[i].isDisabled(4)) continue;
                        if (get.subtype(card) == 'equip5' && players[i].isDisabled(5)) continue;
                        var val1 = get.effect(players[i], card, player, player) + val - get.effect(target, card, player, player);
                        var att1 = get.attitude(player, target);
                        var att2 = get.attitude(player, players[i]);
                        if (!players[i].isEmpty(get.subtype(card))) {
                          val1 -= get.effect(players[i], players[i].getEquip(get.subtype(card)), player, player);
                        }
                        if (att1 > 0 && att2 > 0) {
                          if (card.name == 'baiyin' && target.isDamaged()) val1 += 10;
                          else if (val < 0) val1 = -200;
                          else if (val > 0) val1 += 5;
                        }
                        if (att1 > 0 && att2 < 0) {
                          if (get.effect(players[i], card, player, player) < 0) val1 -= 30;
                        }
                        if (att1 < 0 && att2 > 0) {
                          if (get.effect(target, card, player, player) < 0) val1 += 30;
                        }
                        if (att1 < 0 && att2 < 0) {
                          if (card.name == 'baiyin' && target.isDamaged()) val1 = -100;
                          else if (get.effect(players[i], {
                              name: 'guohe'
                            }, target, target) > 0) val1 -= 10;
                          else val1 += 20;
                        }
                        if (att1 == 0 && att2 == 0) va1 = -100;
                        if (att1 == 0) va1 = -100;
                        if (att2 == 0 && att1 > 0) val1 -= 40;
                        max = Math.max(max, val1);
                      }
                    }
                    return max;
                  }
                  var cards = ui.selected.targets[0].getCards("e");
                  var current = ui.selected.targets[0];
                  var max = -1000;
                  var val = get.effect(target, {
                    name: 'guohe'
                  }, current, player);
                  for (var j = 0; j < cards.length; j++) {
                    var card = cards[j];
                    if (get.subtype(card) == 'equip1' && target.isDisabled(1)) continue;
                    if (get.subtype(card) == 'equip2' && target.isDisabled(2)) continue;
                    if (get.subtype(card) == 'equip3' && target.isDisabled(3)) continue;
                    if (get.subtype(card) == 'equip4' && target.isDisabled(4)) continue;
                    if (get.subtype(card) == 'equip5' && target.isDisabled(5)) continue;
                    var val1 = get.effect(target, card, player, player) + val - get.effect(current, card, player, player);
                    var att1 = get.attitude(player, current);
                    var att2 = get.attitude(player, target);
                    if (!target.isEmpty(get.subtype(card))) {
                      val1 -= get.effect(target, target.getEquip(get.subtype(card)), player, player);
                    }
                    if (att1 > 0 && att2 > 0) {
                      if (card.name == 'baiyin' && current.isDamaged()) val1 += 10;
                      else if (val < 0) val1 = -200;
                      else if (val > 0) val1 += 5;
                    }
                    if (att1 > 0 && att2 < 0) {
                      if (get.effect(target, card, player, player) < 0) val1 -= 30;
                    }
                    if (att1 < 0 && att2 > 0) {
                      if (get.effect(current, card, player, player) < 0) val1 += 30;
                    }
                    if (att1 < 0 && att2 < 0) {
                      if (card.name == 'baiyin' && current.isDamaged()) val1 = -100;
                      else if (get.effect(target, {
                          name: 'guohe'
                        }, current, current) > 0) val1 -= 10;
                      else val1 += 20;
                    }
                    if (att1 == 0 && att2 == 0) va1 = -100;
                    if (att1 == 0) va1 = -100;
                    if (att2 == 0 && att1 > 0) val1 -= 40;
                    max = Math.max(max, val1);
                  }
                  return max;
                });
                next.set("multitarget", true);
                next.set("targetprompt", _status.event.targetprompt || ["被移走", "移动目标"]);
                next.set("prompt", event.prompt || "移动场上的一张装备牌");
                if (event.prompt2) next.set("prompt2", event.prompt2);
                if (event.forced) next.set("forced", true);
                "step 1"
                event.result = result;
                if (result.bool) {
                  player.line2(result.targets, "green");
                  event.targets = result.targets;
                } else {
                  event.finish();
                }
                "step 2"
                if (event.targets.length == 2) {
                  player.choosePlayerCard("e", true, function(button) {
                    var player = _status.event.player;
                    var targets0 = _status.event.targets0;
                    var targets1 = _status.event.targets1;
                    var card = button.link;
                    var val = get.effect(targets1, {
                      name: 'guohe'
                    }, targets0, player)
                    var val1 = get.effect(targets1, card, player, player) + val -
                      get.effect(targets0, card, player, player);
                    var att1 = get.attitude(player, targets0);
                    var att2 = get.attitude(player, targets1);
                    if (!targets1.isEmpty(get.subtype(card))) {
                      val1 -= get.effect(targets1, targets1.getEquip(get.subtype(card)), player, player);
                    }
                    if (att1 > 0 && att2 > 0) {
                      if (card.name == 'baiyin' && targets0.isDamaged()) val1 += 10;
                      else if (val < 0) val1 = -200;
                      else if (val > 0) val1 += 5;
                    }
                    if (att1 > 0 && att2 < 0) {
                      if (get.effect(targets1, card, player, player) < 0) val1 -= 30;
                    }
                    if (att1 < 0 && att2 > 0) {
                      if (get.effect(targets0, card, player, player) < 0) val1 += 30;
                    }
                    if (att1 < 0 && att2 < 0) {
                      if (card.name == 'baiyin' && targets0.isDamaged()) val1 = -100;
                      else if (get.effect(targets1, {
                          name: 'guohe'
                        }, targets0, targets0) > 0) val1 -= 10;
                      else val1 += 20;
                    }
                    if (att1 == 0 && att2 == 0) va1 = -100;
                    if (att1 == 0) va1 = -100;
                    if (att2 == 0 && att1 > 0) val1 -= 40;
                    return val1;
                  }, targets[0]).set("targets0", targets[0]).set("targets1", targets[1]).set("filterButton", function(button) {
                    var targets1 = _status.event.targets1;
                    var card = button.link;
                    if (get.subtype(card) == 'equip1' && !targets1.isDisabled(1)) return true;
                    if (get.subtype(card) == 'equip2' && !targets1.isDisabled(2)) return true;
                    if (get.subtype(card) == 'equip3' && !targets1.isDisabled(3)) return true;
                    if (get.subtype(card) == 'equip4' && !targets1.isDisabled(4)) return true;
                    if (get.subtype(card) == 'equip5' && !targets1.isDisabled(5)) return true;
                    return false;
                  });
                } else {
                  event.finish();
                }
                "step 3"
                if (result.bool && result.links.length) {
                  player.logSkill("zhirong3d8", event.targets);
                  var link = result.links[0];
                  if (get.position(link) == "e") {
                    event.targets[1].equip(link);
                  }
                  event.targets[0].$give(link, event.targets[1], false);
                  game.log(event.targets[0], "的", link, "被移动给了", event.targets[1])
                  event.result.card = link;
                  event.result.position = get.position(link);
                  game.delay();
                } else event.finish();
                "step 4"
                event.targets[0].useCard({
                  name: "guohe",
                  isCard: true
                }, event.targets[1]);
              },
            },

            ningbei3d8: {
              audio: "shouye",
              derivation: "dicheng3d8",
              trigger: {
                player: "phaseJieshuBegin",
              },
              init: function(player) {
                player.storage.ningbei3d8_players = [];
                if (typeof game.storage == "undefined") game.storage = {};
                player.storage.ningbei3d8_card = 0;
                game.storage.ningbei3d8 = [];
              },
              filter: function(event, player) {
                var cards = player.getCards("h");
                for (var i = 0; i < cards.length; i++) {
                  if (get.color(cards[i]) == 'black' && get.type(cards[i]) != 'equip') return true;
                }
                return false;
              },
              direct: true,
              content: function() {
                'step 0'
                player.chooseCardTarget({
                  filterCard: function(card) {
                    return get.color(card) == 'black' && get.type(card) != 'equip';
                  },
                  position: 'h',
                  selectCard: 1,
                  selectTarget: 1,
                  filterTarget: function(card, player, target) {
                    return !target.hasSkill("dicheng3d8");
                  },
                  ai1: function(card) {
                    return 8 - get.value(card);
                  },
                  ai2: function(target) {
                    var s = 0;
                    if (player == target) {
                      if (target.hp == 1 && !target.getEquip(2)) return 5;
                      return 2;
                    } else if (get.attitude(player, target) > 0) {
                      if (target.hp == 1 || target.countCards('h') <= 1) {
                        if (target.getEquip(2)) return 2;
                        return 4;
                      } else if (target.countCards('h') < target.hp && !target.getEquip(2)) return 3;
                      return 1;
                    }
                    return -1;
                  },
                  prompt: '凝备：将一张黑色非装备牌置入防具栏，令一名无“坔城”角色获得“坔城”'
                });
                'step 1'
                if (result.bool) {
                  player.storage.ningbei3d8_players.push(result.targets[0]);
                  for (var i = 0; i < player.storage.ningbei3d8_players.length; i++) {
                    player.storage.ningbei3d8_players[i].storage.ningbei3d8_players = [...player.storage.ningbei3d8_players];
                  }
                  result.targets[0].addSkill("dicheng3d8");
                  result.targets[0].storage.dicheng3d8_player = player;
                  player.logSkill("ningbei3d8", result.targets[0]);
                  result.targets[0].markSkill("dicheng3d8");
                  var ca = result.cards[0];
                  event.ca = [ca.name, ca.nature];
                  var eq = result.cards[0].name + '_equip2';
                  var card = {
                    type: "equip",
                    subtype: "equip2",
                    enable: true,
                    selectTarget: -1,
                    filterTarget: function(card, player, target) {
                      return target == player;
                    },
                    fullimage: true,
                    image: "ext:贴吧精品/image/3d8_lougui.jpg",
                    modTarget: true,
                    allowMultiple: false,
                    content: function() {
                      target.equip(cards[0]);
                    },
                    ai: {
                      basic: {
                        equipValue: 8,
                      },
                    },
                    toself: true,
                  };
                  lib.card[eq] = card;
                  lib.translate[eq] = lib.translate[result.cards[0].name];
                  lib.translate[eq + "_info"] = '【凝备】牌，为娄圭铸造的冰城。';
                  ca.init(game.createCard(eq, ca.suit, ca.number));
                  ca.storage.orname = event.ca;
                  player.storage.ningbei3d8_card = ca;
                  game.storage.ningbei3d8.push(ca);
                  player.equip(ca);
                  if (result.targets[0] != player) player.draw(2);
                } else event.finish();
              },
              group: ["ningbei3d8_lose"],
              subSkill: {
                lose: {
                  trigger: {
                    player: "loseAfter",
                  },
                  priority: 99,
                  direct: true,
                  forceDie: true,
                  filter: function(event, player) {
                    if (event.getParent(2).name == "ningbei3d8") return false;
                    if ((event.parent && event.parent.name != 'swapEquip') && event.type != 'equip') {
                      for (var i = 0; i < event.cards.length; i++) {
                        if (game.storage.ningbei3d8.contains(event.cards[i])) return true;
                      }
                    }
                  },
                  content: function() {
                    "step 0"
                    for (var i = 0; i < trigger.cards.length; i++) {
                      if (game.storage.ningbei3d8.contains(trigger.cards[i])) {
                        game.storage.ningbei3d8.remove(trigger.cards[i]);
                        trigger.cards[i].init(game.createCard(trigger.cards[i].storage.orname[0], trigger.cards[i].suit, trigger.cards[i].number, trigger.cards[i].storage.orname[1]));
                      }
                    }
                  },
                  sub: true,
                },
              },
              ai: {
                effect: {
                  player: function(card, player, target, current) {
                    if (game.storage.ningbei3d8.contains(card) && player.storage.ningbei3d8_card == card) return;
                    if (!player.isPhaseUsing()) return;
                    if (get.type(card) == 'equip' || get.color(card) != 'black') return;
                    var players = game.filterPlayer();
                    var flag = 0;
                    for (var i = 0; i < players.length; i++) {
                      if (get.attitude(player, players[i]) > 0 && !players[i].hasSkill("dicheng3d8")) flag = 1;
                    }
                    if (flag == 0) return;
                    var cards = player.getCards("h");
                    var useful = ai.get.useful(card);
                    var count = 0;
                    for (var i = 0; i < cards.length; i++) {
                      if (ai.get.useful(cards[i]) >= useful) count += 1;
                    }
                    if (count > player.getHandcardLimit()) return [1, -1];
                    else return [1, -3];
                  },
                },
              },
              mod: {
                aiUseful: function(player, card, num) {
                  if (get.type(card) == 'equip' || get.color(card) != 'black') return;
                  var players = game.filterPlayer();
                  var flag = 0;
                  for (var i = 0; i < players.length; i++) {
                    if (get.attitude(player, players[i]) > 0 && !players[i].hasSkill("dicheng3d8")) flag = 1;
                  }
                  if (flag == 0) return;
                  return num + 2;
                },
              },
            },

            dicheng3d8: {
              trigger: {
                player: "damageBegin1",
              },
              mark: false,
              intro: {
                content: function(storage, player, skill) {
                  return "被" + get.translation(player.storage.dicheng3d8_player) + "铸造的冰城保护";
                },
              },
              filter: function(event, player) {
                return event.card && event.card.name == 'sha' && get.color(event.card) == 'black' &&
                  event.notLink();
              },
              forced: true,
              content: function() {
                'step 0'
                var target = player.storage.dicheng3d8_player;
                if (!target.isIn()) event.goto(1);
                else {
                  var card = target.getEquip(2);
                  if (card && game.storage.ningbei3d8.contains(card) && target.storage.ningbei3d8_card == card) {
                    trigger.num -= 1;
                    event.finish();
                  }
                }
                'step 1'
                var players = player.storage.ningbei3d8_players;
                for (var i = 0; i < players.length; i++) {
                  if (players[i].isAlive() && players[i].hasSkill("dicheng3d8")) players[i].removeSkill("dicheng3d8");
                }
              },
              ai: {
                effect: {
                  target: function(card, player, target) {
                    if (player.hasSkillTag('jueqing', false, target)) return;
                    if (card.name != 'sha' || get.color(card) != 'black') return;
                    var dicheng_player = target.storage.dicheng3d8_player;
                    if (!dicheng_player) return;
                    if (!dicheng_player.isIn()) return;
                    var num = get.tag(card, 'damage');
                    var card = dicheng_player.getEquip(2);
                    if (card && game.storage.ningbei3d8.contains(card) && dicheng_player.storage.ningbei3d8_card == card) {
                      if (num) {
                        if (num > 1) return 0.5;
                        return 'zeroplayertarget';
                      }
                    } else return;
                  },
                  player: function(card, player, target) {
                    if (get.subtype(card) != 'equip2') return;
                    var count = 0;
                    var players = game.filterPlayer();
                    if (!player.hasSkill("ningbei3d8")) return;
                    for (var i = 0; i < players.length; i++) {
                      if (players[i].hasSkill("dicheng3d8") && players[i].storage.dicheng3d8_player == player) count += 1;
                    }
                    if (count == 0) return [0, 1];
                    return;
                  },
                },
              },
            },

            jince3d8: {
              audio: "jieming",
              trigger: {
                global: "roundStart",
              },
              filter: function(event, player) {
                return game.roundNumber > 1 && game.hasPlayer(function(current) {
                  return current.isMaxHp(true);
                }) && player.countCards("he") >= 1;
              },
              forced: true,
              content: function() {
                'step 0'
                var players = game.filterPlayer();
                event.big_player = 0;
                for (var i = 0; i < players.length; i++) {
                  if (players[i].isMaxHp(true)) event.big_player = players[i];
                }
                if (event.big_player == 0) event.finish();
                event.big_player.logSkill("jince3d8", player);
                if (event.big_player != player) event.goto(8);
                'step 1'
                player.chooseCard('he', '选择至多两张牌', true, [1, Math.min(player.countCards("he"), 2)])
                  .ai = function(card) {
                    var cards = player.getCards("e");
                    var current = _status.currentPhase;
                    var enemy = 0;
                    current = current.next;
                    if (get.attitude(player, current) < 0) enemy += 1;
                    while (current != player) {
                      if (get.attitude(player, current) < 0) enemy += 1;
                      current = current.next;
                    }
                    if (cards.contains(card)) {
                      if (player.storage.ningbei3d8_card == card) {
                        var card = game.createCard(card.storage.orname[0], card.suit, card.number, card.storage.orname[1]);
                        if (get.value(card) < 6) return 8 - get.value(card);
                        if (enemy >= player.hp) return 8 - get.value(card);
                        return -2;
                      }
                      if (enemy >= player.hp) return 8 - get.value(card);
                      return -2;
                    }
                    if (lib.filter.cardEnabled(card, player) && lib.filter.cardUsable(card, player) && game.hasPlayer(function(current) {
                        return player.canUse(card, current);
                      })) return player.getUseValue(card);
                    return 6 - get.value(card);
                  };
                'step 2'
                if (result.bool) {
                  event.cards = result.cards;
                  event.index = 0;
                } else event.finish();
                'step 3'
                var card = event.cards[event.index];
                if (player.getCards("h") && player.getCards("h").contains(card)) {
                  if (lib.filter.cardEnabled(card, player) && lib.filter.cardUsable(card, player) && game.hasPlayer(function(current) {
                      return player.canUse(card, current);
                    })) player.chooseUseTarget(card);
                  else {
                    player.discard(event.cards[event.index]);
                    player.draw();
                    event.goto(7);
                  }
                } else event.goto(5);
                'step 4'
                if (result.bool) event.goto(7);
                else {
                  player.discard(event.cards[event.index]);
                  player.draw();
                  event.goto(7);
                }
                'step 5'
                player.chooseControl('收回', '重铸', function(event, player) {
                  var card = event.cards[event.index];
                  var current = _status.currentPhase;
                  var enemy = 0;
                  current = current.next;
                  if (get.attitude(player, current) < 0) enemy += 1;
                  while (current != player) {
                    if (get.attitude(player, current) < 0) enemy += 1;
                    current = current.next;
                  }
                  if (player.storage.ningbei3d8_card == card) {
                    var card = game.createCard(card.storage.orname[0], card.suit, card.number, card.storage.orname[1]);
                    if (get.value(card) < 6) return '重铸';
                    if (enemy >= player.hp) return '重铸';
                    return '收回';
                  }
                  if (get.value(card) < 6) return '重铸';
                  if (enemy >= player.hp) return '重铸';
                  return '收回';
                }).set('prompt', '尽策：收回或重铸' + get.translation(event.cards[event.index]));
                'step 6'
                if (result.control == '收回') player.gain(event.cards[event.index], 'gain2');
                else {
                  player.discard(event.cards[event.index]);
                  player.draw();
                }
                'step 7'
                if (event.index == event.cards.length - 1) event.finish();
                else {
                  event.index += 1;
                  event.goto(3);
                }
                'step 8'
                event.big_player.choosePlayerCard('he', player, true, [1, Math.min(player.countCards("he"), 2)], function(button) {
                  if (get.attitude(event.big_player, player) < 0) {
                    if (player.storage.ningbei3d8_card == button.link) return 100;
                    return get.buttonValue(button);
                  } else if (get.attitude(event.big_player, player) > 0) {
                    if (player.storage.ningbei3d8_card == button.link) return -100;
                    return -get.buttonValue(button);
                  }
                  return 0;
                });
                'step 9'
                if (result.bool) {
                  event.cards = result.links;
                  event.index = 0;
                } else event.finish();
                'step 10'
                var card = event.cards[event.index];
                if (player.getCards("h") && player.getCards("h").contains(card)) {
                  if (lib.filter.cardEnabled(card, player) && lib.filter.cardUsable(card, player) && game.hasPlayer(function(current) {
                      return player.canUse(card, current);
                    })) player.chooseUseTarget(card);
                  else {
                    player.discard(event.cards[event.index]);
                    player.draw();
                    event.goto(14);
                  }
                } else event.goto(12);
                'step 11'
                if (result.bool) event.goto(14);
                else {
                  player.discard(event.cards[event.index]);
                  player.draw();
                  event.goto(14);
                }
                'step 12'
                player.chooseControl('收回', '重铸', function(event, player) {
                  var card = event.cards[event.index];
                  if (player.storage.ningbei3d8_card == card) {
                    var card = game.createCard(card.storage.orname[0], card.suit, card.number, card.storage.orname[1]);
                    if (get.value(card) < 6) return '重铸';
                    return '收回';
                  }
                  if (get.value(card) < 6) return '重铸';
                  return '收回';
                }).set('prompt', '尽策：收回或重铸' + get.translation(event.cards[event.index]));
                'step 13'
                if (result.control == '收回') player.gain(event.cards[event.index], 'gain2');
                else {
                  player.discard(event.cards[event.index]);
                  player.draw();
                }
                'step 14'
                if (event.index == event.cards.length - 1) event.finish();
                else {
                  event.index += 1;
                  event.goto(10);
                }
              },
            },

            fenlun3d8: {
              audio: "jlsg_kuangyan",
              group: ["fenlun3d8_filter", "fenlun3d8_before"],
              trigger: {
                global: "phaseJieshuBegin"
              },
              multitarget: true,
              multiline: true,
              filter: function(event, player) {
                if (event.player == player) return false;
                if (player.countCards("h") == 0) return false;
                if (event.player.countCards("h") == 0) return false;
                if (player.hasSkillTag("noCompareSource")) return false;
                if (event.player.hasSkillTag("noCompareTarget")) return false;
                return player.storage.fenlun3d8_filter == true;
              },
              check: function(event, player) {
                var target = event.player;
                if (get.attitude(player, target) >= 0) return false;
                var hs = player.getCards('h');
                var check = player.hasSkill("qicai3d8");
                var current = _status.currentPhase;
                var enemy = 0;
                current = current.next;
                while (current != player) {
                  if (get.attitude(player, current) < 0) enemy += 1;
                  current = current.next;
                }
                var enemy_zhu = 0;
                current = _status.currentPhase;
                current = current.next;
                while (current != game.zhu) {
                  if (get.attitude(player, current) < 0) enemy_zhu += 1;
                  current = current.next;
                }
                for (var i = 0; i < hs.length; i++) {
                  if (get.value(hs[i]) <= 6) {
                    if (check && player.storage.qicai3d8 >= 3) return true;
                    if (check && (enemy == 0 || enemy_zhu == 0)) return true;
                    if (check && player.countCards('h') == 1 && player.storage.qicai3d8 <= 2) return true;
                    if (hs[i].number >= 7 + player.storage.qicai3d8) return true;
                  }
                  if (get.value(hs[i]) <= 7) {
                    if (check && player.storage.qicai3d8 >= 3) return true;
                    if (check && (enemy == 0 || enemy_zhu == 0)) return true;
                    if (check && player.countCards('h') == 1 && player.storage.qicai3d8 <= 1) return true;
                    if (hs[i].number >= 8 + player.storage.qicai3d8) return true;
                  }
                  if (get.value(hs[i]) <= 8) {
                    if (check && player.storage.qicai3d8 >= 3) return true;
                    if (check && (enemy == 0 || enemy_zhu == 0)) return true;
                    if (check && player.countCards('h') == 1 && player.storage.qicai3d8 <= 0) return true;
                    if (hs[i].number >= 9 + player.storage.qicai3d8) return true;
                  }
                }
                return false;
              },
              content: function() {
                "step 0"
                event.list = [];
                event.list.add(trigger.player);
                player.chooseTarget("请选择另一名拼点的角色", function(card, player, target) {
                  return player.canCompare(target) && target != trigger.player;
                }).set("ai", function(target) {
                  var player = _status.event.player;
                  return -get.attitude(player, target);
                });
                "step 1"
                if (result.bool) {
                  var target = result.targets[0];
                  event.list.add(target);
                }
                player.line(event.list);
                player.chooseToCompare(event.list);
              },
              subSkill: {
                filter: {
                  trigger: {
                    global: ["useCard", "respond"],
                  },
                  popup: false,
                  forced: true,
                  filter: function(event, player) {
                    return Array.isArray(event.respondTo) && event.respondTo[0] == _status.currentPhase;
                  },
                  content: function() {
                    player.storage.fenlun3d8_filter = true;
                  }
                },
                before: {
                  trigger: {
                    global: "phaseBefore"
                  },
                  popup: false,
                  forced: true,
                  content: function() {
                    player.storage.fenlun3d8_filter = false;
                  }
                },
              },
            },

            qicai3d8: {
              audio: "jlsg_caijie",
              group: ["qicai3d8_compare", "qicai3d8_gain"],
              trigger: {
                player: "loseAfter",
                global: ["equipAfter", "addJudgeAfter", "gainAfter", "loseAsyncAfter"],
              },
              init: function(player) {
                player.storage.qicai3d8 = 0;
              },
              frequent: true,
              filter: function(event, player) {
                if (_status.currentPhase == player) return false;
                if (player.countCards("h")) return false;
                if (player.storage.qicai3d8 > 2) return false;
                var evt = event.getl(player);
                return evt && evt.player == player && evt.hs && evt.hs.length > 0;
              },
              content: function() {
                var num = 3 - player.storage.qicai3d8;
                if (num > 0) player.draw(num, "bottom");
              },
              subSkill: {
                compare: {
                  trigger: {
                    player: ["compare", "compareMultipleAfter"],
                    target: ["compare", "compareMultipleAfter"]
                  },
                  filter: function(event, player) {
                    if (player == event.player) return event.num1 <= event.num2;
                    else return event.num1 >= event.num2;
                  },
                  LastDo: true,
                  popup: false,
                  forced: true,
                  content: function() {
                    player.storage.qicai3d8++;
                    player.syncStorage('qicai3d8');
                    player.markSkill('qicai3d8');
                  }
                },
                gain: {
                  trigger: {
                    global: "roundStart",
                    player: "gainAfter"
                  },
                  filter: function(event, player) {
                    if (event.getParent(2).name == "qicai3d8") return false;
                    return true;
                  },
                  popup: false,
                  forced: true,
                  content: function() {
                    player.storage.qicai3d8 = 0;
                    player.syncStorage('qicai3d8');
                    player.markSkill('qicai3d8');
                  },
                }
              },
              mark: true,
              intro: {
                content: "本轮拼点已失败#次",
              },
            },

            jianjun3d8: {
              audio: "jlsg_yijian",
              global: ["jianjun3d8_mark", "jianjun3d8_mark2", "jianjun3d8_disable"],
              trigger: {
                target: "useCardToBefore",
              },
              filter: function(event, player) {
                if (event.player == player) return false;
                if (event.player.countCards("hej") == 0) return false;
                return true;
              },
              direct: true,
              content: function() {
                'step 0'
                event.count = 0;
                event.card_count = trigger.player.countCards("hej");
                event.flag1 = 0;
                event.flag2 = 0;
                event.expose_cards = [];
                event.recall_cards = [];
                if (trigger.player.storage.jianjun3d8_mark.length > 0) event.goto(1);
                else event.goto(3);
                'step 1'
                player.chooseCardButton('弃置“渐军”明置的牌', trigger.player.storage.jianjun3d8_mark, [1, 1], function(button) {
                  return true;
                }, false).set('ai', function(button) {
                  var card = button.link;
                  var att = get.attitude(player, trigger.player);
                  var flag = 0;
                  if (att >= 0) return -1;
                  var cards = trigger.player.getCards("ej");
                  if (cards.length == 0) return get.value(card);
                  cards.sort(function(a, b) {
                    var val1 = get.effect(trigger.player, a, player, player);
                    if (a.name == 'baiyin' && trigger.player.isDamaged()) val1 = 10;
                    var val2 = get.effect(trigger.player, b, player, player);
                    if (b.name == 'baiyin' && trigger.player.isDamaged()) val2 = 10;
                    return val1 - val2;
                  });
                  var index = Math.min(1, 3 - event.count);
                  var card_1 = cards[index - 1];
                  return trigger.player.getUseValue(card) + 5 - trigger.player.getUseValue(card_1);
                }).set('filterButton', function(button) {
                  return !event.expose_cards.contains(button.link);
                });
                'step 2'
                if (result.bool) {
                  event.flag1 = 1;
                  player.logSkill("jianjun3d8", trigger.player);
                  game.log(player, "令", trigger.player, "弃置明置的", result.links[0]);
                  event.count += 1;
                  trigger.player.storage.jianjun3d8_mark.remove(result.links[0]);
                  trigger.player.discard(result.links);
                  trigger.player.syncStorage("jianjun3d8_mark");
                  trigger.player.markSkill("jianjun3d8_mark");
                }
                if (event.count == 3 || event.count == event.card_count) event.finish();
                if (trigger.player.countCards("hej") <= trigger.player.storage.jianjun3d8_mark.length + event.recall_cards.length) {
                  if (event.flag == 1) {
                    event.flag1 = 0;
                    event.goto(1);
                  } else event.finish();
                } else event.goto(3);
                'step 3'
                player.choosePlayerCard('明置手牌或令其将场上的牌收回手牌', 'hej', trigger.player, false, [1, 1], function(button) {
                  var card = button.link;
                  var att = get.attitude(player, trigger.player);
                  if (att == 0) return 0;
                  var j_cards = trigger.player.getCards("j");
                  if (j_cards.length > 0 && j_cards.contains(card)) return -get.effect(trigger.player, card, player, player);
                  var e_cards = trigger.player.getCards("e");
                  if (e_cards.length > 0 && e_cards.contains(card)) {
                    if (trigger.player.isDamaged() && card.name == 'baiyin') {
                      if (att > 0) return -10;
                      return 10;
                    }
                    return -get.effect(trigger.player, card, player, player);
                  }
                  if (att > 0) return -1;
                  return 1;
                }).set('filterButton', function(button) {
                  return !trigger.player.storage.jianjun3d8_mark.contains(button.link) && !event.recall_cards.contains(button.link);
                });
                'step 4'
                if (result.bool) {
                  event.flag2 = 1;
                  event.count += 1;
                  player.logSkill('jianjun3d8', trigger.player);
                  event.cards = result.links;
                  event.index = 0;
                } else event.goto(6);
                'step 5'
                var card = event.cards[0];
                if (trigger.player.getCards("h") && trigger.player.getCards("h").contains(card)) {
                  game.log(player, "令", trigger.player, "从手牌中明置", result.links[0]);
                  trigger.player.storage.jianjun3d8_mark.push(card);
                  event.expose_cards.push(card);
                  trigger.player.syncStorage("jianjun3d8_mark");
                  trigger.player.markSkill("jianjun3d8_mark");
                } else {
                  game.log(player, "令", trigger.player, "收回场上的", result.links[0]);
                  trigger.player.gain(card, "gain2");
                  event.recall_cards.push(card);
                  trigger.player.storage.jianjun3d8_disable.push(card);
                }
                'step 6'
                if (event.flag1 == 0 && event.flag2 == 0) event.finish();
                event.flag1 = 0;
                event.flag2 = 0;
                if (event.count == 3 || event.count == event.card_count) event.finish();
                else if (trigger.player.storage.jianjun3d8_mark.length - event.expose_cards.length > 0) event.goto(1);
                else event.goto(3);
              },
              effect: {
                target: function(card, player, target, current) {
                  if (!player.hasFriend()) return;
                  if (get.attitude(player, target) >= 0) return;
                  var check1 = player.storage.jianjun3d8_mark.length;
                  var check2 = player.countCards("e");
                  if (!check1 && !check2) return [1, 0, 1, -1];
                  if (check1 && check2) return [1, 0, 1, -3];
                  return [1, 0, 1, -2];
                },
              },
              group: ["jianjun3d8_init", "jianjun3d8_use"],
              subSkill: {
                init: {
                  trigger: {
                    global: ["gameStart"],
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    var players = game.filterPlayer();
                    for (var i = 0; i < players.length; i++) {
                      players[i].storage.jianjun3d8_mark = [];
                      players[i].storage.jianjun3d8_disable = [];
                    }
                  },
                  sub: true,
                },
                use: {
                  audio: "jlsg_yijian",
                  trigger: {
                    player: "useCard",
                  },
                  filter: function(event, player) {
                    if (!event.targets) return false;
                    for (var i = 0; i < event.targets.length; i++) {
                      if (event.targets[i] != player && event.targets[i].countCards("hej") > 0) return true;
                    }
                    return false;
                  },
                  direct: true,
                  content: function() {
                    'step 0'
                    event.jianjun3d8_targets = [];
                    for (var i = 0; i < trigger.targets.length; i++) {
                      if (trigger.targets[i] == player) continue;
                      if (trigger.targets[i].countCards("hej") == 0) continue;
                      event.jianjun3d8_targets.push(trigger.targets[i]);
                    }
                    event.card_count = 0;
                    for (var i = 0; i < event.jianjun3d8_targets.length; i++) {
                      event.jianjun3d8_targets[i].storage.expose_cards = [];
                      event.jianjun3d8_targets[i].storage.recall_cards = [];
                      event.card_count += event.jianjun3d8_targets[i].countCards("hej");
                    }
                    event.count = 0;
                    'step 1'
                    player.chooseTarget('渐军：请选择一名角色', function(card, player, target) {
                      if (!event.jianjun3d8_targets.contains(target)) return false;
                      return target.countCards("hej") > 0 &&
                        (target.countCards("hej") > target.storage.jianjun3d8_mark.length + target.storage.recall_cards.length ||
                          target.storage.jianjun3d8_mark.length > target.storage.expose_cards.length);
                    }).set('ai', function(target) {
                      var att = get.attitude(player, target);
                      if (att == 0) return 0;
                      if (att > 0) {
                        var cards = target.getCards("ej");
                        if (cards.length == 0) return -1;
                        cards.sort(function(a, b) {
                          var val1 = get.effect(target, a, player, player);
                          if (a.name == 'baiyin' && target.isDamaged()) val1 = 10;
                          var val2 = get.effect(target, b, player, player);
                          if (b.name == 'baiyin' && target.isDamaged()) val2 = 10;
                          return val1 - val2;
                        });
                        var eff = get.effect(target, cards[0], player, player);
                        return -eff;
                      }
                      var show_cards = [];
                      for (var i = 0; i < target.storage.jianjun3d8_mark.length; i++) {
                        var card = target.storage.jianjun3d8_mark[i];
                        if (!target.storage.expose_cards.contains(card)) show_cards.push(card);
                      }

                      if (show_cards.length > 0) {
                        show_cards.sort(function(a, b) {
                          return target.getUseValue(b) - target.getUseValue(a);
                        });
                      }

                      var cards = target.getCards("ej");
                      if (cards.length > 0) {
                        cards.sort(function(a, b) {
                          var val1 = get.effect(target, a, player, player);
                          if (a.name == 'baiyin' && target.isDamaged()) val1 = 10;
                          var val2 = get.effect(target, b, player, player);
                          if (b.name == 'baiyin' && target.isDamaged()) val2 = 10;
                          return val1 - val2;
                        });
                      }
                      var val = 0;
                      if (show_cards.length > 0) val = Math.max(target.getUseValue(show_cards[0]) + 5, val);
                      if (cards.length > 0) val = Math.max(target.getUseValue(cards[0]), val);
                      if (val > 0) return val;
                      return Math.max(1, 4 - target.hp);
                    });
                    'step 2'
                    if (result.bool) {
                      player.storage.jianjun3d8_target = result.targets[0];
                      if (player.storage.jianjun3d8_target.storage.jianjun3d8_mark.length - player.storage.jianjun3d8_target.storage.expose_cards.length > 0) event.goto(3);
                      else event.goto(5);
                    } else event.finish();
                    'step 3'
                    player.chooseCardButton('弃置“渐军”明置的牌', player.storage.jianjun3d8_target.storage.jianjun3d8_mark, [1, 1], function(button) {
                      return true;
                    }, false).set('ai', function(button) {
                      var card = button.link;
                      var att = get.attitude(player, player.storage.jianjun3d8_target);
                      var flag = 0;
                      if (att >= 0) return -1;
                      var cards = player.storage.jianjun3d8_target.getCards("ej");
                      if (cards.length == 0) return get.value(card);
                      cards.sort(function(a, b) {
                        var val1 = get.effect(player.storage.jianjun3d8_target, a, player, player);
                        if (a.name == 'baiyin' && player.storage.jianjun3d8_target.isDamaged()) val1 = 10;
                        var val2 = get.effect(player.storage.jianjun3d8_target, b, player, player);
                        if (b.name == 'baiyin' && player.storage.jianjun3d8_target.isDamaged()) val2 = 10;
                        return val1 - val2;
                      });
                      var card_1 = cards[0];
                      return player.storage.jianjun3d8_target.getUseValue(card) + 5 - player.storage.jianjun3d8_target.getUseValue(card_1);
                    }).set('filterButton', function(button) {
                      return !player.storage.jianjun3d8_target.storage.expose_cards.contains(button.link);
                    });
                    'step 4'
                    if (result.bool) {
                      event.count += 1;
                      player.logSkill("jianjun3d8", player.storage.jianjun3d8_target);
                      game.log(player, "令", player.storage.jianjun3d8_target, "弃置明置的", result.links[0]);
                      player.storage.jianjun3d8_target.storage.jianjun3d8_mark.remove(result.links[0]);
                      player.storage.jianjun3d8_target.discard(result.links);
                      player.storage.jianjun3d8_target.syncStorage("jianjun3d8_mark");
                      player.storage.jianjun3d8_target.markSkill("jianjun3d8_mark");
                      if (event.count == 3 || event.count == event.card_count) event.finish();
                    } else if (player.storage.jianjun3d8_target.countCards("hej") <= player.storage.jianjun3d8_target.storage.jianjun3d8_mark.length + player.storage.jianjun3d8_target.storage.recall_cards.length) {
                      event.goto(1);
                    } else event.goto(5);
                    'step 5'
                    player.choosePlayerCard('明置手牌或令其将场上的牌收回手牌', 'hej', player.storage.jianjun3d8_target, false, [1, 1], function(button) {
                      var card = button.link;
                      var att = get.attitude(player, player.storage.jianjun3d8_target);
                      if (att == 0) return 0;
                      var j_cards = player.storage.jianjun3d8_target.getCards("j");
                      if (j_cards.length > 0 && j_cards.contains(card)) return -get.effect(player.storage.jianjun3d8_target, card, player, player);
                      var e_cards = player.storage.jianjun3d8_target.getCards("e");
                      if (e_cards.length > 0 && e_cards.contains(card)) {
                        if (player.storage.jianjun3d8_target.isDamaged() && card.name == 'baiyin') {
                          if (att > 0) return -10;
                          return 10;
                        }
                        return -get.effect(player.storage.jianjun3d8_target, card, player, player);
                      }
                      if (att > 0) return -1;
                      return 1;
                    }, true).set('filterButton', function(button) {

                      return !player.storage.jianjun3d8_target.storage.jianjun3d8_mark.contains(button.link) && !player.storage.jianjun3d8_target.storage.recall_cards.contains(button.link);
                    });
                    'step 6'
                    if (result.bool) {
                      event.count += 1;
                      player.logSkill('jianjun3d8', player.storage.jianjun3d8_target);
                      var card = result.links[0];
                      if (player.storage.jianjun3d8_target.getCards("h") && player.storage.jianjun3d8_target.getCards("h").contains(card)) {
                        game.log(player, "令", player.storage.jianjun3d8_target, "从手牌中明置", result.links[0]);
                        player.storage.jianjun3d8_target.storage.jianjun3d8_mark.push(card);
                        player.storage.jianjun3d8_target.storage.expose_cards.push(card);
                        player.storage.jianjun3d8_target.syncStorage("jianjun3d8_mark");
                        player.storage.jianjun3d8_target.markSkill("jianjun3d8_mark");
                      } else {
                        game.log(player, "令", player.storage.jianjun3d8_target, "收回场上的", result.links[0]);
                        player.storage.jianjun3d8_target.gain(card, "gain2");
                        player.storage.jianjun3d8_target.storage.recall_cards.push(card);
                        player.storage.jianjun3d8_target.storage.jianjun3d8_disable.push(card);
                      }
                    } else event.finish();
                    'step 7'
                    if (event.count == 3 || event.count == event.card_count) event.finish();
                    else event.goto(1);
                  },
                },
              },
            },

            jianjun3d8_mark: {
              marktext: "渐",
              intro: {
                mark: function(dialog, content, player) {
                  var hs = player.storage.jianjun3d8_mark;
                  if (hs.length) {
                    dialog.add('<div class="text center">' + get.translation(player) + '明置的牌</div>');
                    dialog.addSmall(hs);
                  } else {
                    dialog.addText('无明置手牌');
                  }
                },
                content: function(content, player) {
                  var hs = player.storage.jianjun3d8_mark;
                  if (hs.length) {
                    return get.translation(hs);
                  } else {
                    return '无明置手牌';
                  }
                },
              },
            },

            jianjun3d8_mark2: {
              trigger: {
                player: "loseEnd",
              },
              forced: true,
              silent: true,
              content: function() {
                if (player.storage.jianjun3d8_mark) {
                  for (var i = 0; i < player.storage.jianjun3d8_mark.length; i++) {
                    if (trigger.cards.contains(player.storage.jianjun3d8_mark[i])) {
                      player.storage.jianjun3d8_mark.splice(i--, 1);
                    }
                  }
                }
                if (player.storage.jianjun3d8_mark.length == 0) player.unmarkSkill('jianjun3d8_mark');
                player.updateMarks();
              },
              popup: false,
            },

            jianjun3d8_disable: {
              mod: {
                cardEnabled: function(card, player) {
                  if (!card.cards) return;
                  if (player.storage.jianjun3d8_disable.contains(card.cards[0])) return false;
                },
                cardUsable: function(card, player) {
                  if (!card.cards) return;
                  if (player.storage.jianjun3d8_disable.contains(card.cards[0])) return false;
                },
              },
              trigger: {
                player: "phaseAfter",
              },
              forced: true,
              silent: true,
              content: function() {
                player.storage.jianjun3d8_disable = [];
              },
            },

            mingye3d8: {
              audio: "nzry_zhizheng",
              group: "mingye3d8_outside",
              trigger: {
                player: "useCard"
              },
              forced: true,
              filter: function(event, player) {
                if (player != _status.currentPhase) return false;
                if (player.hasSkill("mingye3d82")) return false;
                return get.type(event.card) == "basic" || get.type(event.card) == "trick";
              },
              content: function() {
                "step 0"
                player.addTempSkill("mingye3d82", "roundStart");
                trigger.cancel();
                if (trigger.card.name == "sha") player.getStat().card.sha--;
                if (trigger.card.name == "jiu") player.getStat().card.jiu--;
                "step 1"
                player.draw(2);
                if (player.isDamaged()) {
                  var next = player.chooseToDiscard("是否弃置一张红桃牌回复1点体力？", {
                    suit: "heart"
                  });
                  next.set("ai", function(card) {
                    if (player.hp >= 2) return 8 - get.useful(card);
                    return 10 - get.useful(card);
                  });
                } else event.finish();
                "step 2"
                if (result.bool) player.recover();
                event.finish();
              },
              subSkill: {
                outside: {
                  audio: "nzry_zhizheng",
                  trigger: {
                    player: "useCard"
                  },
                  forced: true,
                  filter: function(event, player) {
                    if (player == _status.currentPhase) return false;
                    if (player.hasSkill("mingye3d83")) return false;
                    return get.type(event.card) == "basic" || get.type(event.card) == "trick";
                  },
                  content: function() {
                    "step 0"
                    player.addTempSkill("mingye3d83", "roundStart");
                    trigger.cancel();
                    if (trigger.card.name == "sha") player.getStat().card.sha--;
                    if (trigger.card.name == "jiu") player.getStat().card.jiu--;
                    "step 1"
                    player.draw(2);
                    if (player.isDamaged()) {
                      var next = player.chooseToDiscard("是否弃置一张红桃牌回复1点体力？", {
                        suit: "heart"
                      });
                      next.set("ai", function(card) {
                        if (player.hp >= 2) return 8 - get.useful(card);
                        return 10 - get.useful(card);
                      });
                    } else event.finish();
                    "step 2"
                    if (result.bool) player.recover();
                    event.finish();
                  },
                }
              },
              mod: {
                aiOrder: function(player, card, num) {
                  if (!player.isPhaseUsing()) return;
                  if (player.hasSkill("mingye3d82")) return;
                  if (get.type(card) != 'trick' && get.type(card) != 'basic') return;
                  var val = 100 - num - get.value(card);
                  if (player.isDamaged() && get.suit(card) == 'heart' && player.countCards("h", {
                      suit: "heart"
                    }) == 1) {
                    val -= 5;
                  }
                  return val;
                },
              },
              ai: {
                effect: {
                  player: function(card, player, target, current) {
                    if (!player.isPhaseUsing()) {
                      if (!player.hasSkill("mingye3d82")) return [0, 1, 0, 0];
                      return;
                    }
                    if (player.hasSkill("mingye3d82")) return;
                    if (get.type(card) != 'trick' && get.type(card) != 'basic') return;
                    return [0, 1, 0, 0];
                  },
                },
              },
            },

            mingye3d82: {},
            mingye3d83: {},

            mingye3d8_get: {
              audio: "nzry_zhizheng",
              group: "mingye3d8_get_outside",
              trigger: {
                player: "useCard",
              },
              forced: true,
              mark: false,
              intro: {
                content: function(storage, player, skill) {
                  return get.translation(player.storage.mingye3d8_player) + "一党";
                },
              },
              filter: function(event, player) {
                if (player != _status.currentPhase) return false;
                if (player.hasSkill("mingye3d8_get2")) return false;
                return get.type(event.card) == "basic" || get.type(event.card) == "trick";
              },
              content: function() {
                "step 0"
                player.addTempSkill("mingye3d8_get2", "roundStart");
                trigger.cancel();
                if (trigger.card.name == "sha") player.getStat().card.sha--;
                if (trigger.card.name == "jiu") player.getStat().card.jiu--;
                player.draw(2);
                if (!player.storage.mingye3d8_player.isAlive()) event.finish();
                "step 1"
                player.chooseBool("是否令" + get.translation(player.storage.mingye3d8_player) + "获得" + get.translation(trigger.card) + "?").ai = function() {
                  var target = player.storage.mingye3d8_player;
                  return get.attitude(player, target) > 0;
                };
                "step 2"
                if (result.bool) {
                  var target = player.storage.mingye3d8_player;
                  target.gain(trigger.cards, "gain2");
                }
              },
              subSkill: {
                outside: {
                  audio: "nzry_zhizheng",
                  trigger: {
                    player: "useCard",
                  },
                  forced: true,
                  filter: function(event, player) {
                    if (player == _status.currentPhase) return false;
                    if (player.hasSkill("mingye3d8_get3")) return false;
                    return get.type(event.card) == "basic" || get.type(event.card) == "trick";
                  },
                  content: function() {
                    "step 0"
                    player.addTempSkill("mingye3d8_get3", "roundStart");
                    trigger.cancel();
                    if (trigger.card.name == "sha") player.getStat().card.sha--;
                    if (trigger.card.name == "jiu") player.getStat().card.jiu--;
                    player.draw(2);
                    if (!player.storage.mingye3d8_player.isAlive()) event.finish();
                    "step 1"
                    player.chooseBool("是否令" + get.translation(player.storage.mingye3d8_player) + "获得" + get.translation(trigger.card) + "?").ai = function() {
                      var target = player.storage.mingye3d8_player;
                      return get.attitude(player, target) > 0;
                    };
                    "step 2"
                    if (result.bool) {
                      var target = player.storage.mingye3d8_player;
                      target.gain(trigger.cards, "gain2");
                    }
                  },
                },
              },
              mod: {
                aiOrder: function(player, card, num) {
                  if (!player.isPhaseUsing()) return;
                  if (player.hasSkill("mingye3d8_get2")) return;
                  if (get.type(card) != 'trick' && get.type(card) != 'basic') return;
                  var val = 100 - num - get.value(card);
                  if (get.attitude(player, player.storage.mingye3d8_player) > 0) {
                    val = -val + 100;
                  }
                  return val;
                },
              },
              ai: {
                effect: {
                  player: function(card, player, target, current) {
                    if (!player.isPhaseUsing()) {
                      if (!player.hasSkill("mingye3d8_get2")) return [0, 1, 0, 0];
                      return;
                    }
                    if (player.hasSkill("mingye3d8_get2")) return;
                    if (get.type(card) != 'trick' && get.type(card) != 'basic') return;
                    return [0, 1, 0, 0];
                  },
                },
              },
            },

            mingye3d8_get2: {},
            mingye3d8_get3: {},

            danghu3d8: {
              audio: "nzry_lijun1",
              trigger: {
                player: "changeHp",
              },
              direct: true,
              filter: function(event, player) {
                if (player.hasSkill("danghu3d82")) return false;
                return true;
              },
              content: function() {
                "step 0"
                player.chooseTarget(get.prompt("danghu3d8"), "选择一名角色获得“命也”", function(card, player, target) {
                  return target != player && !target.hasSkill("mingye3d8") && !target.hasSkill("mingye3d8_get");
                }).set("ai", function(target) {
                  var att = get.attitude(player, target);
                  if (att == 0) return 0;
                  if (att > 0) return (target.countCards("h") - 1) * (target.hp - 1);
                  return (3 - player.countCards("h")) * (3 - player.hp);
                });
                "step 1"
                if (result.bool) {
                  var target = result.targets[0];
                  player.logSkill("danghu3d8", target);
                  player.addTempSkill("danghu3d82", "roundStart");
                  target.addTempSkill("mingye3d8_get", "roundStart");
                  target.markSkill("mingye3d8_get");
                  target.storage.mingye3d8_player = player;
                }
              }
            },

            danghu3d82: {},

            xiaheng3d8: {
              group: ["xiaheng3d8_players"],
              audio: "xianghai",
              trigger: {
                player: "phaseUseBegin",
              },
              init: function(player) {
                player.storage.xiaheng3d8_players = [];
              },
              filter: function(event, player) {
                return true;
              },
              forced: true,
              content: function() {
                'step 0'
                player.chooseTarget("侠横：弃置一名角色两张牌", function(card, player, target) {
                  return true;
                }, true).ai = function(target) {
                  var att = get.attitude(player, target);
                  var flag = 1;
                  if (player.storage.xiaheng3d8_players.length < 3 && !player.storage.xiaheng3d8_players.contains(target)) flag = 2;
                  if (player.storage.xiaheng3d8_players.contains(player)) {
                    if (att > 0) {
                      if (target.countCards("he") == 0) return 0 + (flag - 1);
                      return -1;
                    }
                    if (target.countCards("he") == 0) return 0 + (flag - 1);
                    if (target.countCards("he") == 1) return [2 + (flag - 1)] * Math.max(1, 5 - target.hp);
                    return -att * Math.max(1, 5 - target.countCards("he")) * flag * Math.max(1, 5 - target.hp);
                  }
                  var cards = player.countCards("he");
                  var count = 0;
                  for (var i = 0; i < cards.length; i++) {
                    if (get.value(cards[i]) < 6) count += 1;
                  }
                  if (target == player) {
                    if (count >= 2) return cards.length;
                    if (cards.length == 0) return 10;
                    if (cards.length <= 2) return -1;
                    if (player.hp >= 3) return 3;
                    return -1;
                  }
                  if (att > 0) {
                    if (target.countCards("he") == 0) return 0 + (flag - 1);
                    return -1;
                  }
                  if (target.countCards("he") == 0) return 0 + (flag - 1);
                  if (target.countCards("he") == 1) return 1 + (flag - 1);
                  return -att * Math.max(1, 5 - target.countCards("he")) * flag;
                };
                'step 1'
                if (result.bool) {
                  event.target1 = result.targets[0];
                  player.logSkill("xiaheng3d8", event.target1);
                  if (!player.storage.xiaheng3d8_players.contains(event.target1)) player.storage.xiaheng3d8_players.push(event.target1);
                  player.syncStorage('xiaheng3d8_players');
                  player.markSkill('xiaheng3d8_players');
                  if (event.target1.countCards("he") == 0) event.goto(3);
                  var count = Math.min(2, event.target1.countCards("he"));
                  player.discardPlayerCard(event.target1, "he", count, true).set('filterButton', function(button) {
                    return true;
                  });
                } else event.finish();
                'step 2'
                if (!result.bool) event.finish();
                'step 3'
                player.chooseTarget("侠横：对一名角色造成一点伤害", function(card, player, target) {
                  return true;
                }, true).ai = function(target) {
                  var flag = 0;
                  if (player.storage.xiaheng3d8_players.contains(player)) {
                    var val = get.damageEffect(target, player, player);
                    if (event.target1 == target) val -= 6 * (Math.min(5 - player.hp, 1));
                    if (event.target1 != player && target != player) val -= 8 * (Math.min(5 - player.maxHp, 1));
                    return val;
                  }
                  if (target == player) {
                    if (player.hp >= 4) return 15;
                    if (player.hp == 3) return 7.5;
                    return -10;
                  }
                  var val = get.damageEffect(target, player, player);
                  if (event.target1 == target) val -= 6 * (Math.min(5 - player.hp, 1));
                  if (event.target1 != player && target != player) val -= 8 * (Math.min(5 - player.maxHp, 1));
                  return val;
                };
                'step 4'
                if (result.bool) {
                  event.target2 = result.targets[0];
                  player.logSkill("xiaheng3d8", event.target2);
                  if (!player.storage.xiaheng3d8_players.contains(event.target2)) player.storage.xiaheng3d8_players.push(event.target2);
                  player.syncStorage('xiaheng3d8_players');
                  player.markSkill('xiaheng3d8_players');
                  event.target2.damage();
                } else event.finish();
                'step 5'
                if (event.target1 != player && event.target2 != player) player.loseMaxHp();
                if (event.target1 == event.target2) player.loseHp();
                if (player.storage.xiaheng3d8_players.length >= 3 && player.storage.xiaheng3d8_players.contains(player)) {
                  game.log(player, "修改了“侠横”");
                  player.removeSkill("xiaheng3d8");
                  player.removeSkill("xiaheng3d8_players");
                  player.addTempSkill("xiaheng3d8_temp", "phaseUseAfter");
                  player.addSkill("xiaheng_gai_3d8");
                }
              },
            },

            xiaheng3d8_players: {
              sub: true,
              mark: true,
              marktext: "横",
              intro: {
                content: function(storage, player, skill) {
                  var players = player.storage.xiaheng3d8_players;
                  if (players.length == 0) return "没有其他角色成为过“侠横”的目标";
                  var str = "";
                  for (var i = 0; i < players.length; i++) {
                    str += get.translation(players[i]);
                    if (i < players.length - 1) str += "、"
                  }
                  return "成为过“侠横”的目标的角色：" + str;
                },
              },
            },

            xiaheng3d8_temp: {},

            xiaheng_gai_3d8: {
              audio: "chuhai",
              trigger: {
                player: "phaseUseBegin",
              },
              filter: function(event, player) {
                return !player.hasSkill("xiaheng3d8_temp");
              },
              forced: true,
              content: function() {
                'step 0'
                player.chooseTarget("侠横：弃置一名角色两张牌", function(card, player, target) {
                  return true;
                }, true).ai = function(target) {
                  var att = get.attitude(player, target);
                  if (att > 0) return -1;
                  if (att == 0) return 0;
                  if (target.countCards("he") == 0) return 0;
                  if (target.countCards("he") == 1) return Math.max(1, 5 - target.hp);
                  return Math.max(1, 5 - target.countCards("he")) * Math.max(1, 5 - target.hp);
                };
                'step 1'
                if (result.bool) {
                  event.target1 = result.targets[0];
                  player.logSkill("xiaheng_gai_3d8", event.target1);
                  if (event.target1.countCards("he") == 0) event.goto(3);
                  var count = Math.min(2, event.target1.countCards("he"));
                  player.discardPlayerCard(event.target1, "he", count, true).set('filterButton', function(button) {
                    return true;
                  });
                } else event.finish();
                'step 2'
                if (!result.bool) event.finish();
                'step 3'
                player.chooseTarget("侠横：对一名角色造成一点伤害", function(card, player, target) {
                  return true;
                }, true).ai = function(target) {
                  return get.damageEffect(target, player, player);
                };
                'step 4'
                if (result.bool) {
                  event.target2 = result.targets[0];
                  player.logSkill("xiaheng_gai_3d8", event.target2);
                  event.target2.damage();
                } else event.finish();
              },
            },

            jiexing3d8: {
              audio: "jlsg_youxia",
              group: "jiexing3d8_equip",
              unique: true,
              limited: true,
              skillAnimation: true,
              animationColor: "gray",
              trigger: {
                global: "recoverBefore",
              },
              filter: function(event, player) {
                if (event.player == player) return false;
                return player.isDamaged();
              },
              check: function(event, player) {
                var target = event.player;
                if (get.attitude(player, target) > 0) return false;
                return true;
              },
              content: function() {
                "step 0"
                trigger.cancel();
                "step 1"
                player.recover(trigger.num);
                "step 2"
                player.awakenSkill("jiexing3d8");
                player.addSkill("jiexing3d8_restore");
              },
              subSkill: {
                equip: {
                  audio: "jlsg_youxia",
                  unique: true,
                  skillAnimation: true,
                  animationColor: "gray",
                  trigger: {
                    global: "useCardToBefore",
                  },
                  filter: function(event, player) {
                    if (event.player == player) return false;
                    if (get.type(event.card) != "equip") return false;
                    var subtype = get.subtype(event.card);
                    if (subtype == "equip1") return player.isEmpty(1);
                    if (subtype == "equip2") return player.isEmpty(2);
                    if (subtype == "equip3") return player.isEmpty(3);
                    if (subtype == "equip4") return player.isEmpty(4);
                    if (subtype == "equip5") return player.isEmpty(5);
                    return false;
                  },
                  check: function(event, player) {
                    var target = event.player;
                    if (get.attitude(player, target) >= 0) return false;
                    var subtype = get.subtype(event.card);
                    var card = event.card;
                    if (subtype == "equip1") return get.effect(player, card, player) > 0;
                    if (subtype == "equip2") return get.effect(player, card, player) > 0;
                    if (subtype == "equip3") return get.effect(player, card, player) > 0;
                    if (subtype == "equip4") return get.effect(player, card, player) > 0;
                    if (subtype == "equip5") return get.effect(player, card, player) > 0;
                    return true;
                  },
                  content: function() {
                    "step 0"
                    trigger.cancel();
                    "step 1"
                    player.equip(trigger.card);
                    "step 2"
                    player.awakenSkill("jiexing3d8");
                    player.addSkill("jiexing3d8_restore");
                  },
                  sub: true,
                },
              },
            },

            "jiexing3d8_restore": {
              trigger: {
                player: ["recoverAfter", "equipAfter"],
              },
              filter: function(event, player) {
                if (event.getParent(2).name == "jiexing3d8" || event.getParent(2).name == "jiexing3d8_equip") return false;
                return player.awakenedSkills.contains("jiexing3d8");
              },
              forced: true,
              content: function() {
                player.restoreSkill("jiexing3d8");
              },
            },

            bailei3d8: {
              audio: "jlsg_jiexi",
              trigger: {
                global: "roundStart",
              },
              direct: true,
              filter: function(event, player) {
                if (game.hasPlayer(function(current) {
                    return current.isMaxHp(true);
                  })) return true;
                var list = game.filterPlayer(function(current) {
                  return current.hp == 1;
                });
                if (list.length == 1) return true;
                return false;
              },
              content: function() {
                "step 0"
                var list = game.filterPlayer(function(current) {
                  return current.hp == 1;
                });
                if (list.length != 1) list = [];
                player.chooseTarget(get.prompt("bailei3d8"), "杀死体力唯一为1的角色，或对体力唯一最大的角色造成2点伤害", function(card, player, target) {
                  return target.isMaxHp(true) || list.contains(target);
                }).set("ai", function(target) {
                  var player = _status.event.player;
                  return get.damageEffect(target, player, player);
                });
                "step 1"
                if (result.bool) {
                  var target = result.targets[0];
                  player.logSkill("bailei3d8", target);
                  if (target.hp == 1) target.die().source = player;
                  else target.damage(2);
                }
              },
            },

            xiaoxing3d8: {
              audio: "XS_juebi",
              forced: true,
              mod: {
                attackFrom: function(from, to, distance) {
                  return distance - 3;
                },
                maxHandcard: function(player, num) {
                  return num + 3;
                },
              },
              group: ["xiaoxing3d8_dying"],
              subSkill: {
                dying: {
                  trigger: {
                    player: "dying",
                  },
                  forced: true,
                  popup: false,
                  filter: function(event, player) {
                    return event.getParent().name == 'damage' && event.source && event.source.getEquip(1) && game.roundNumber > 1;
                  },
                  content: function() {
                    'step 0'
                    var target = player;
                    trigger.source.chooseControl('是', '否', function(event, player) {
                      var att = get.attitude(trigger.source, target);
                      if (att < 0) return '是';
                      return '否';
                    }).set('prompt', '是否废除武器栏，令' + get.translation(player) + '失去“枭行”？');
                    'step 1'
                    if (result.control == '是') {
                      trigger.source.logSkill("xiaoxing3d8", player);
                      trigger.source.disableEquip(1);
                      game.log(player, '失去“枭行”');
                      player.removeSkill("xiaoxing3d8");
                    }
                  },
                },
              }
            },

            langzhi3d8: {
              trigger: {
                player: "phaseJieshuBegin"
              },
              filter: function(event, player) {
                return game.hasPlayer(function(current) {
                  return player.inRange(current) && current.countCards("he") > 0;
                });
              },
              /*check: function(event, player) {
                var players = game.filterPlayer();
                var count = 0;
                var count1 = 0;
                for(var i = 0;i<players.length;i++){
                  if(players[i] == player) continue;
                  if(player.inRange(players[i]) && players[i].countCards("he") > 0 && get.attitude(player,players[i])<=0){
                    count += 1;
                    if(players[i].countCards("he") >= 2) count1 += 1;
                  }
                }
                if(count == 0) return false;
                if(count == 1 && count1 == 0){
                  var cards = player.getCards("he");
                  var count2 = 0;
                  for(var i = 0;i<cards.length;i++){
                    if(get.value(cards[i])<=7) count2 += 1;
                  }
                  if(count2 == 0) return false;
                }
                return true;
              },*/
              content: function() {
                "step 0"
                event.targets = game.filterPlayer(function(current) {
                  return player.inRange(current) && current.countCards("he") > 0;
                }).sortBySeat();
                player.line(event.targets);
                var next = player.chooseCardOL("he", event.targets, "请选择要展示的牌", true).set("ai", function(card) {
                  if (get.attitude(_status.event.player, player) <= 0) return -get.value(card);
                  return get.value(card);
                }).set("source", player);
                next._args.remove("glow_result");
                "step 1"
                var cards = [];
                event.videoId = lib.status.videoId++;
                for (var i = 0; i < event.targets.length; i++) cards.push(result[i].cards[0]);
                event.cards = cards;
                game.log(player, "展示了", event.targets, "的", cards);
                game.broadcastAll(function(targets, cards, id, player) {
                  var dialog = ui.create.dialog(get.translation(player) + "发动了【狼志】", cards);
                  dialog.videoId = id;
                  var getName = function(target) {
                    if (target._tempTranslate) return target._tempTranslate;
                    var name = target.name;
                    if (lib.translate[name + "_ab"]) return lib.translate[name + "_ab"];
                    return get.translation(name);
                  }
                  for (var i = 0; i < event.targets.length; i++) {
                    dialog.buttons[i].querySelector(".info").innerHTML = getName(event.targets[i]) + get.translation(cards[i].suit) + get.translation(cards[i].number);
                  }
                }, targets, cards, event.videoId, player);
                game.delay(4);
                "step 2"
                game.broadcastAll("closeDialog", event.videoId);
                event.dialog = ui.create.dialog("请选择要获得或替换的牌", cards);
                var getName = function(target) {
                  if (target._tempTranslate) return target._tempTranslate;
                  var name = target.name;
                  if (lib.translate[name + "_ab"]) return lib.translate[name + "_ab"];
                  return get.translation(name);
                }
                for (var i = 0; i < event.targets.length; i++) {
                  event.dialog.buttons[i].querySelector(".info").innerHTML = getName(event.targets[i]) + get.translation(cards[i].suit) + get.translation(cards[i].number);
                }
                player.chooseButton(event.dialog, [1, event.targets.length]).set("ai", function(button) {
                  var flag = 0;
                  player.storage.langzhi3d8_cards = event.cards;
                  var cards = player.getCards("he");
                  cards.sort(function(a, b) {
                    return get.value(a) - get.value(b);
                  });
                  var get_cards = [];
                  for (var i = 0; i < player.storage.langzhi3d8_cards.length; i++) {
                    if (get.attitude(player, get.owner(player.storage.langzhi3d8_cards[i])) <= 0) {
                      get_cards.push(player.storage.langzhi3d8_cards[i]);
                    }
                  }
                  get_cards.sort(function(a, b) {
                    return get.value(b) - get.value(a);
                  });
                  var count = 0;
                  for (var i = 0; i < cards.length; i++) {
                    if (i < get_cards.length) count += get.value(get_cards[i]) - get.value(cards[i]);
                  }
                  var val = 0;
                  for (var i = 0; i < get_cards.length; i++) {
                    val += get.value(get_cards[i]);
                  }
                  if (player.hp == 1 && player.countCards("h") <= 1 && val > count) flag = 1;
                  if (player.hp <= 2 && player.countCards("h") <= 2 && val - count > 7) flag = 1;
                  if (player.hp <= 3 && player.countCards("h") <= 3 && val - count > Math.max(5, 20 - 3 * game.roundNumber)) flag = 1;
                  if (val - count > Math.max(5, 30 - 3 * game.roundNumber)) flag = 1;
                  if (game.roundNumber==1 && player.hp>=3) flag = 0;
                  if (flag == 1) {
                    var owner = get.owner(button.link);
                    var att = get.attitude(player, owner);
                    if (att > 0) {
                      if (owner.hp <= 2 || owner.countCards("h") <= 2) return -1;
                      if (Math.random() > 0.5) return 1;
                      return -1;
                    }
                    return get.value(button.link);
                  }
                  var owner = get.owner(button.link);
                  var get_cards = [...player.storage.langzhi3d8_cards];
                  get_cards.sort(function(a, b) {
                    var att1 = get.attitude(player, get.owner(a));
                    var att2 = get.attitude(player, get.owner(b));
                    if(att1*att2<0) return att1 - att2;
                    if(att1*att2 == 0 && (att1>0 || att2>0)) return att1-att2;
                    if(att1*att2 == 0 && (att1<0 || att2<0)) return get.value(b) - get.value(a);
                    if(att1<0&&att2<0) return get.value(b) - get.value(a);
                    if(att1==0&&att2==0) return get.value(b) - get.value(a);
                    return get.value(a) - get.value(b);
                  });
                  var change_cards = [];
                  var index = Math.min(cards.length, get_cards.length);
                  for (var i = 0; i < index; i++) {
                    var att1 = get.attitude(player, get.owner(get_cards[i]));
                    if(att1>0) return Math.random()>0.7;
                    if(get.value(cards[i])>get.value(get_cards[i])) change_cards.push(get_cards[i]);
                  }
                  for(var i = 0;i<change_cards.length;i++){
                    if(change_cards[i] == button.link) return 1;
                  }
                  return -1;
                });
                "step 3"
                if (result.bool) {
                  event.links = result.links;
                  event.targetss = [];
                  var players = game.filterPlayer();
                  for (i = 0; i < players.length; i++) {
                    for (j = 0; j < event.links.length; j++) {
                      if (players[i].getCards("he").contains(event.links[j])) event.targetss.push(players[i]);
                    }
                  }
                  if (result.links.length > player.countCards("he")) {
                    player.gain(event.links, "gain2");
                    player.removeSkill("langzhi3d8");
                    event.finish();
                    return;
                  } else{
                    player.chooseControl("选项一", "选项二",function(event, player) {
                      var flag = 0;
                      player.storage.langzhi3d8_cards = event.cards;
                      var cards = player.getCards("he");
                      cards.sort(function(a, b) {
                        return get.value(a) - get.value(b);
                      });
                      var get_cards = [];
                      for (var i = 0; i < player.storage.langzhi3d8_cards.length; i++) {
                        if (get.attitude(player, get.owner(player.storage.langzhi3d8_cards[i])) <= 0) {
                          get_cards.push(player.storage.langzhi3d8_cards[i]);
                        }
                      }
                      get_cards.sort(function(a, b) {
                        return get.value(b) - get.value(a);
                      });
                      var count = 0;
                      for (var i = 0; i < cards.length; i++) {
                        if (i < get_cards.length) count += get.value(get_cards[i]) - get.value(cards[i]);
                      }
                      var val = 0;
                      for (var i = 0; i < get_cards.length; i++) {
                        val += get.value(get_cards[i]);
                      }
                      if (player.hp == 1 && player.countCards("h") <= 1 && val > count) flag = 1;
                      if (player.hp <= 2 && player.countCards("h") <= 2 && val - count > 7) flag = 1;
                      if (player.hp <= 3 && player.countCards("h") <= 3 && val - count > Math.max(5, 20 - 3 * game.roundNumber)) flag = 1;
                      if (val - count > Math.max(5, 30 - 3 * game.roundNumber)) flag = 1;
                      if (game.roundNumber==1 && player.hp>=3) flag = 0;
                      if (flag == 1) return '选项一';
                      return '选项二';
                    }).set("prompt", "狼志").set("choiceList", ["获得这些牌", "用等量的牌替换这些牌"]);
                  }
                } else event.finish();
                "step 4"
                if (result.control == "选项一") {
                  player.gain(event.links, "gain2");
                  player.removeSkill("langzhi3d8");
                  event.finish();
                  return;
                } else {
                  player.chooseCardTarget({
                    prompt: "用" + event.links.length + "张牌替换这些牌",
                    prompt2: "操作提示：先按顺序选中所有要替换的牌，然后再按顺序选择目标角色",
                    selectCard: event.links.length,
                    selectTarget: event.links.length,
                    filterTarget: function(card, player, target) {
                      return event.targetss.contains(target);
                    },
                    ai1: function(card) {
                      var index = ui.selected.cards.length;
                      var target = event.targetss[i];
                      if (get.attitude(player, target) > 0) {
                        if (target.hp <= 2 || target.countCards("h") <= 2) return get.value(card);
                        return 1;
                      }
                      return 1000 - get.value(card);
                    },
                    ai2: function(target) {
                      return 1000 - event.targetss.indexOf(target);
                    },
                    complexSelect: true,
                    position: "he",
                    forced: true,
                  });
                }
                "step 5"
                if (result.bool) {
                  while (result.cards.length) {
                    var target = result.targets.shift();
                    var card = result.cards.shift();
                    target.gain(card, player);
                    player.$giveAuto(card, target);
                  }
                  event.next.sort(function(a, b) {
                    return lib.sort.seat(a.player, b.player);
                  });
                  player.gain(event.links, "gain2");
                }
              },
            },

            fuyi3d8: {
              audio: "jlsg_muma",
              zhuSkill: true,
              trigger: {
                global: "die",
              },
              direct: true,
              filter: function(event, player) {
                if (!player.hasZhuSkill('fuyi3d8')) return false;
                if (player.hasSkill("xiaoxing3d8") && player.hasSkill("langzhi3d8")) return false;
                return event.source && event.source.group == 'qun' && event.source != player;
              },
              content: function() {
                'step 0'
                event.list = [];
                event.count = 0;
                if (!player.hasSkill("xiaoxing3d8")) event.list.push("枭行");
                if (!player.hasSkill("langzhi3d8")) event.list.push("狼志");
                event.list.push("取消");
                'step 1'
                var target = player;
                trigger.source.chooseControl(event.list, function(event, player) {
                  var att = get.attitude(trigger.source, target);
                  if (att <= 0) return "取消";
                  if (event.list.contains("枭行")) return "枭行";
                  return "狼志";
                }).set('prompt', '是否令' + get.translation(player) + '恢复技能？');
                'step 2'
                if (result.control == "取消") event.finish();
                if (result.control == "枭行") {
                  trigger.source.logSkill("fuyi3d8", player);
                  event.list.remove("枭行");
                  player.addSkill("xiaoxing3d8");
                  event.count += 1;
                }
                if (result.control == "狼志") {
                  trigger.source.logSkill("fuyi3d8", player);
                  event.list.remove("狼志");
                  player.addSkill("langzhi3d8");
                  event.count += 1;
                }
                if (event.list.length >= 2) event.goto(1);
                else if (event.count == 2) {
                  player.draw(3);
                  player.removeSkill("fuyi3d8");
                }
              },
            },

            leili3d8: {
              enable: "phaseUse",
              usable: 1,
              filterTarget: function(card, player, target) {
                return player != target;
              },
              content: function() {
                "step 0"
                if (!target.isLinked()) target.link();
                "step 1"
                if (!player.isLinked()) player.link();
                "step 2"
                player.useCard({
                  name: "sha",
                  nature: "thunder",
                  isCard: true
                }, target, false, 'noai');
              },
              ai: {
                result: {
                  target: -1,
                  player: function(player) {
                    return player.isLinked() ? 0 : -0.8;
                  },
                },
                order: 2,
                expose: 0.3,
                effect: {
                  target: function(card) {
                    if (card.name == 'tiesuo') {
                      return 0.5;
                    }
                  },
                },
              },
            },
            fengxing3d8: {
              group: ["fengxing3d8_1", "fengxing3d8_2"],
              subSkill: {
                "1": {
                  trigger: {
                    player: "linkBegin",
                  },
                  filter: function(event, player) {
                    return !player.isLinked();
                  },
                  content: function() {
                    player.moveCard(true);
                  },
                  sub: true,
                },
                "2": {
                  trigger: {
                    player: "loseAfter",
                  },
                  direct: true,
                  filter: function(event, player) {
                    return event.es && event.es.length > 0;
                  },
                  content: function() {
                    "step 0"
                    var controls = ['摸牌'];
                    if (player.isLinked()) {
                      controls.push('重置武将牌');
                    }
                    player.chooseControl(controls);
                    "step 1"
                    event.control = result.control;
                    switch (event.control) {
                      case '摸牌':
                        player.draw();
                        event.finish();
                        break;
                      case '重置武将牌':
                        if (event.target.isLinked()) player.link();
                        event.finish();
                        break;
                    }
                  },
                  sub: true,
                },
              },
            },

            dijiang3d8: {
              group: "dijiang3d8_club",
              trigger: {
                global: "damageSource",
              },
              filter: function(event, player) {
                return (event.card && event.card.name == 'sha' && !player.hasSkill("dijiang3d82"));
              },
              direct: true,
              content: function() {
                "step 0"
                if (game.hasPlayer(function(player) {
                    return player != trigger.source && !trigger.source.inRange(player);
                  })) {
                  player.chooseTarget("是否发动涤疆？选择一名角色对其造成1点伤害", function(card, player, target) {
                    return target != trigger.source && !trigger.source.inRange(target);
                  }).set('ai', function(target) {
                    return get.damageEffect(target, player, player);
                  });
                }
                "step 1"
                if (result.bool) {
                  player.logSkill("dijiang3d8", result.targets);
                  player.addTempSkill("dijiang3d82", "roundStart");
                  result.targets[0].damage();
                }
              },
              ai: {
                expose: 0.3,
              },
              subSkill: {
                club: {
                  sub: true,
                  trigger: {
                    player: "useCard",
                  },
                  forced: true,
                  filter: function(event, player) {
                    return get.suit(event.card) == 'club' && player.hasSkill("dijiang3d82");
                  },
                  content: function() {
                    player.removeSkill("dijiang3d82");
                  },
                },
              },
            },
            "dijiang3d82": {},

            yuwang3d8: {
              trigger: {
                global: "dying",
              },
              filter: function(event, player) {
                return event.player != player;
              },
              forced: true,
              content: function() {
                player.gainMaxHp();
                player.addTempSkill("yuwang3d82", "dyingAfter");
                player.addTempSkill("yuwang3d83", "dyingAfter");
              },
            },

            "yuwang3d82": {
              trigger: {
                global: "useCardToTarget",
              },
              forced: true,
              filter: function(event, player) {
                if (event.card.name == 'tao') return true;
                if (event.targets.contains(player)) return false;
                return false;
              },
              autodelay: true,
              content: function() {
                trigger.getParent().targets.add(player);
                trigger.player.line(player, 'green');
              },
            },
            "yuwang3d83": {
              trigger: {
                player: "recoverAfter",
              },
              forced: true,
              filter: function(event, player) {
                return player.hasSkill("yuwang3d8") && player.hp == player.maxHp;
              },
              content: function() {
                player.removeSkill("yuwang3d8");
              },
            },

            weizheng3d8: {
              group: ["weizheng3d8_add", "weizheng3d8_remove"],
              trigger: {
                player: "phaseDiscardBefore",
              },
              filter: function(event, player) {
                return player.countMark('weizheng3d8') > 0 && player.countMark('weizheng3d8') <= game.countPlayer();
              },
              content: function() {
                "step 0"
                player.addTempSkill("weizheng3d83");
                player.chooseTarget(player.countMark('weizheng3d8'), true, function(card, player, target) {
                  return true;
                }).set('ai', function(target) {
                  var players = game.filterPlayer();
                  var wugu = 0;
                  var taoyuan = 0;
                  var nanman = 0;
                  var wanjian = 0;
                  var tiesuo = 0;
                  for (var i = 0; i < players.length; i++) {
                    var att = get.attitude(player, players[i]);
                    if (att > 0) wugu += 1;
                    if (att > 0 && players[i].isDamaged()) taoyuan += 2;
                    if (att < 0 && !players[i].getEquip("tengjia") && players[i].countCards("h") <= 2) {
                      nanman += 1.5;
                      wanjian += 1.5;
                    } else if (att < 0 && !players[i].getEquip("tengjia") && players[i].countCards("h") > 2) {
                      nanman += 1;
                      wanjian += 1;
                    }
                    if (att < 0 && !players[i].isLinked()) tiesuo += 1;
                  }
                  wugu = Math.min(player.countMark('weizheng3d8'), wugu);
                  taoyuan = Math.min(player.countMark('weizheng3d8'), taoyuan);
                  nanman = Math.min(player.countMark('weizheng3d8'), nanman);
                  wanjian = Math.min(player.countMark('weizheng3d8'), wanjian);
                  tiesuo = Math.min(player.countMark('weizheng3d8'), tiesuo);
                  if (nanman >= wugu && nanman >= taoyuan && nanman >= tiesuo) {
                    if (get.attitude(player, target) < 0 && !target.getEquip("tengjia")) return 2;
                    if (get.attitude(player, target) > 0 && !target.getEquip("tengjia")) return -2;
                    if (get.attitude(player, target) > 0) return -1;
                    return 0;
                  }
                  if (tiesuo > taoyuan && tiesuo > wugu && tiesuo > nanman) {
                    if (get.attitude(player, target) < 0 && !target.isLinked()) return 2;
                    if (get.attitude(player, target) > 0 && target.isLinked()) return 1;
                    if (get.attitude(player, target) > 0 && target.isLinked()) return -2;
                    if (get.attitude(player, target) < 0 && target.isLinked()) return -3;
                    return 0;
                  }
                  if (taoyuan >= wugu) {
                    if (get.attitude(player, target) > 0 && target.isDamaged()) return 2;
                    if (get.attitude(player, target) < 0 && target.isDamaged()) return -2;
                    if (get.attitude(player, target) >= 0) return 1;
                    return 0;
                  }
                  return get.attitude(player, target);
                });

                "step 1"
                if (result.bool) {
                  var length = result.targets.length;
                  for (var i = 0; i < length; i++) {
                    result.targets[i].addTempSkill('weizheng3d82');
                  }
                } else {
                  event.finish();
                }
                "step 2"
                var list = ["nanman", "wanjian", "wugu", "taoyuan", "tiesuo"];
                player.chooseButton(['请选择一个牌名', [list, 'vcard'], true]).set('ai', function(button) {
                  var players = game.filterPlayer(function(current) {
                    return current.hasSkill("weizheng3d82");
                  });
                  var wugu = 0;
                  var taoyuan = 0;
                  var nanman = 0;
                  var wanjian = 0;
                  var tiesuo = 0;
                  for (var i = 0; i < players.length; i++) {
                    var att = get.attitude(player, players[i]);
                    if (att > 0) wugu += 1;
                    if (att > 0 && players[i].isDamaged()) taoyuan += 2;
                    if (att < 0 && !players[i].getEquip("tengjia") && players[i].countCards("h") <= 2) {
                      nanman += 1.5;
                      wanjian += 1.5;
                    } else if (att < 0 && !players[i].getEquip("tengjia") && players[i].countCards("h") > 2) {
                      nanman += 1;
                      wanjian += 1;
                    }
                    if (att < 0 && !players[i].isLinked()) tiesuo += 1;
                  }
                  wugu = Math.min(player.countMark('weizheng3d8'), wugu);
                  taoyuan = Math.min(player.countMark('weizheng3d8'), taoyuan);
                  nanman = Math.min(player.countMark('weizheng3d8'), nanman);
                  wanjian = Math.min(player.countMark('weizheng3d8'), wanjian);
                  tiesuo = Math.min(player.countMark('weizheng3d8'), tiesuo);
                  if (nanman >= wugu && nanman >= taoyuan && nanman >= tiesuo) {
                    if (button.link[2] == 'nanman') return 1;
                    if (button.link[2] == 'wanjian') return 1;
                    return -1;
                  }
                  if (tiesuo > taoyuan && tiesuo > wugu && tiesuo > nanman) {
                    if (button.link[2] == 'tiesuo') return 1;
                    return -1;
                  }
                  if (taoyuan >= wugu) {
                    if (button.link[2] == 'taoyuan') return 1;
                    return -1;
                  }
                  if (button.link[2] == 'wugu') return 1;
                  return -1;
                });
                "step 3"
                if (result.bool) {
                  var name = result.links[0][2];
                } else {
                  event.finish();
                }
                "step 4"
                var list = game.filterPlayer(function(current) {
                  return current.hasSkill("weizheng3d82");
                });
                player.useCard({
                  name: result.links[0][2],
                  isCard: true
                }, list);
              },
              subSkill: {
                add: {
                  sub: true,
                  popup: false,
                  trigger: {
                    player: "useCardToPlayered",
                  },
                  forced: true,
                  filter: function(event, player) {
                    if (event.getParent().triggeredTargets3.length > 1) return false;
                    if (!player.isPhaseUsing()) return false;
                    return true;
                  },
                  content: function() {
                    player.addMark('weizheng3d8', trigger.targets.length);
                  },
                },
                remove: {
                  sub: true,
                  popup: false,
                  trigger: {
                    player: "phaseJieshuBegin",
                  },
                  forced: true,
                  filter: function(event, player) {
                    return player.countMark("weizheng3d8") > 0;
                  },
                  content: function() {
                    player.removeMark("weizheng3d8", player.countMark("weizheng3d8"));
                  },
                },
              },
            },
            "weizheng3d82": {},
            "weizheng3d83": {
              mod: {
                maxHandcard: function(player, num) {
                  return player.countMark('weizheng3d8');
                },
              },
            },

            zhiduan3d8: {
              mark: true,
              locked: false,
              zhuanhuanji: true,
              marktext: "制",
              intro: {
                content: function(storage, player, skill) {
                  if (player.storage.zhiduan3d8 == true) return '你的回合内，你可以视为使用一张【无懈可击】';
                  return '你的回合外，你可以视为使用一张【无懈可击】';
                },
              },
              group: ["zhiduan3d8_1", "zhiduan3d8_2"],
              subSkill: {
                "1": {
                  enable: "chooseToUse",
                  viewAs: {
                    name: "wuxie",
                    isCard: true,
                  },
                  filterCard: function() {
                    return false;
                  },
                  viewAsFilter: function(player) {
                    return player !== _status.currentPhase && (player.storage.zhiduan3d8 == false || player.storage.zhiduan3d8 == undefined);
                  },
                  selectCard: -1,
                  precontent: function() {
                    player.storage.zhiduan3d8 = true;
                  },
                  prompt: "视为使用一张无懈可击",
                  ai: {
                    respondWuxie: true,
                    basic: {
                      useful: [6, 4],
                      value: [6, 4],
                    },
                    result: {
                      player: 1,
                    },
                    expose: 0.2,
                  },
                  sub: true,
                },
                "2": {
                  enable: "chooseToUse",
                  viewAs: {
                    name: "wuxie",
                    isCard: true,
                  },
                  filterCard: function() {
                    return false
                  },
                  viewAsFilter: function(player) {
                    return player == _status.currentPhase && player.storage.zhiduan3d8 == true;
                  },
                  selectCard: -1,
                  precontent: function() {
                    player.storage.zhiduan3d8 = false;
                  },
                  prompt: "视为使用一张无懈可击",
                  ai: {
                    respondWuxie: true,
                    basic: {
                      useful: [6, 4],
                      value: [6, 4],
                    },
                    result: {
                      player: 1,
                    },
                    expose: 0.2,
                  },
                  sub: true,
                },
              },
            },

            haolie3d8: {
              mark: true,
              locked: false,
              zhuanhuanji: true,
              marktext: "豪",
              intro: {
                content: function(storage, player, skill) {
                  if (player.storage.haolie3d8 == true) return '当你失去牌后，你可以弃置当前回合角色的一张牌';
                  return '出牌阶段，你可弃置一名其他角色一张手牌，若为基本牌，视为你对其使用一张【杀】';
                },
              },
              group: ["haolie3d8_1", "haolie3d8_2"],
              subSkill: {
                "1": {
                  sub: true,
                  audio: 2,
                  prompt: "出牌阶段，你可弃置一名其他角色一张手牌，若为基本牌，视为你对其使用一张【杀】",
                  enable: "phaseUse",
                  filter: function(event, player) {
                    return player.storage.haolie3d8 != true;
                  },
                  filterTarget: function(card, player, target) {
                    return target != player && target.countCards('h') > 0;
                  },
                  content: function() {
                    "step 0"
                    player.storage.haolie3d8 = true;
                    player.discardPlayerCard(target, 'h', true);
                    "step 1"
                    if (get.type(result.cards[0]) != 'basic') {
                      event.finish();
                    } else {
                      player.useCard({
                        name: "sha",
                        isCard: true
                      }, target, false, 'noai');
                    }

                  },
                  ai: {
                    order: 4,
                    expose: 0.2,
                    result: {
                      target: function(player, target) {
                        if (target.hasSkillTag('noh')) return -0.5;
                        if (target.countCards("h") == 1) return -2;
                        if (target.countCards("h") == 2) return -1;
                        return -0.8;
                      }
                    },
                    threaten: 1.1,
                  },
                },
                "2": {
                  sub: true,
                  audio: 2,
                  trigger: {
                    player: "loseEnd",
                  },
                  filter: function(event, player) {
                    return _status.currentPhase.countCards('he') > 0 && player.storage.haolie3d8 == true;
                  },
                  check: function(event, player) {
                    var target = _status.currentPhase;
                    var att = get.attitude(player, target);
                    if (att <= 0) return true;
                    if (target != player) {
                      if (target.countCards("he") == 1) {
                        if (target.countCards("h") == 1 && !target.hasSkillTag("noh")) return false;
                        if (target.countCards("e", {
                            subtype: "equip2"
                          }) == 1 && !target.hasSkillTag("noe")) return false;
                        return true;
                      }
                    }
                    var cards = player.getCards("he");
                    if (cards.length == 1 && get.value(cards[0]) >= 7) return false;
                    return true;
                  },
                  content: function() {
                    player.storage.haolie3d8 = false;
                    player.discardPlayerCard(_status.currentPhase, 'he', true);
                  },
                },
              },
            },

            hengxiao3d8: {
              group: ["hengxiao3d8_1", "hengxiao3d8_2", "hengxiao3d8_3", "hengxiao3d8_4"],
              trigger: {
                player: ["phaseZhunbeiBefore", "phaseJudgeBefore", "phaseDrawBefore", "phaseDiscardBefore", "phaseJieshuBefore"],
              },
              forced: true,
              popup: false,
              content: function() {
                trigger.cancel();
              },
              subSkill: {
                "1": {
                  trigger: {
                    player: "phaseUseBegin",
                  },
                  forced: true,
                  content: function() {
                    "step 0"
                    if (!player.storage.hengxiao3d8) player.storage.hengxiao3d8 = 0;
                    "step 1"
                    player.draw(4 - player.storage.hengxiao3d8);

                  },
                  sub: true,
                },
                "2": {
                  trigger: {
                    player: "phaseUseEnd",
                  },
                  popup: false,
                  forced: true,
                  priority: 10,
                  content: function() {
                    player.discard(player.getCards("h"));
                  },
                  sub: true,
                },
                "3": {
                  trigger: {
                    player: "phaseUseEnd",
                  },
                  forced: true,
                  filter: function(event, player) {
                    var history = player.getHistory('useCard', function(evt) {
                      return evt.getParent('phaseUse') == event;
                    });
                    for (var i = 0; i < history.length; i++) {
                      if (history[i].card.name == 'sha') return true;
                    }
                    return false;
                  },
                  content: function() {
                    "step 0"
                    player.storage.hengxiao3d8++;
                    "step 1"
                    var next = player.phaseUse();
                    event.next.remove(next);
                    trigger.next.push(next);
                  },
                  sub: true,
                },
                "4": {
                  trigger: {
                    player: "phaseEnd",
                  },
                  forced: true,
                  popup: false,
                  priority: 5,
                  content: function() {
                    delete player.storage.hengxiao3d8;
                  },
                  sub: true,
                },
              },
            },

            zongchi3d8: {
              trigger: {
                global: "phaseBefore",
              },
              priority: 10000,
              firstDo: true,
              filter: function(event, player) {
                if (player.countDisabled() >= 5) return false;
                return event.player == _status.roundStart || _status.roundSkipped;
              },
              check: function(event, player) {
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i] == player) continue;
                  if (get.attitude(player, players[i]) >= 0) continue;
                  if (players[i].hp <= 2 && (!players[i].getEquip("tengjia") && !players[i].getEquip("bagua") && !players[i].getEquip("renwang"))) return true;
                }
                var danger = 0;
                for (var i = 0; i < players.length; i++) {
                  if (players[i] == player) continue;
                  if (get.attitude(player, players[i]) >= 0) continue;
                  if (get.distance(players[i], player, 'attack') <= 1) danger += 1;
                }
                if (danger >= player.hp) return true;
                return false;
              },
              content: function() {
                "step 0"
                player.chooseToDisable();
                "step 1"
                player.chooseControl(function(event, player) {
                  var players = game.filterPlayer();
                  for (var i = 0; i < players.length; i++) {
                    if (players[i] == player) continue;
                    if (get.attitude(player, players[i]) >= 0) continue;
                    if (players[i].hp <= 2 && (!players[i].getEquip("tengjia") && !players[i].getEquip("bagua") && !players[i].getEquip("renwang"))) return '选项一';
                  }
                  return '选项二';
                }).set('prompt', '纵驰').set('choiceList', ['你最先进行回合，且本轮其他角色视为在你攻击范围内', '你最后进行回合，且本轮你视为在其他角色攻击范围外']);
                "step 2"
                if (result.control == '选项一') {
                  player.addTempSkill("zongchi3d8_1");
                  var next = player.insertPhase();
                  event.next.remove(next);
                  trigger.next.push(next);
                  player.addSkill("zongchi3d8_skip2");
                }
                if (result.control == '选项二') {
                  player.addTempSkill("zongchi3d8_2", "roundStart");
                  player.addSkill("zongchi3d8_skip");
                  player.addSkill("zongchi3d8_3");
                  player.addSkill("zongchi3d8_4");
                }
              },
              ai: {
                threaten: 3
              },
              subSkill: {
                "1": {
                  mark: true,
                  marktext: "纵",
                  intro: {
                    content: "其他角色视为在你攻击范围内",
                  },
                  mod: {
                    attackFrom: function() {
                      return -Infinity;
                    },
                  },
                  sub: true,
                },
                "2": {
                  mark: true,
                  marktext: "纵",
                  intro: {
                    content: "你视为在其他角色攻击范围外",
                  },
                  mod: {
                    globalTo: function() {
                      return +Infinity;
                    },
                  },
                  sub: true,
                },
                "3": {
                  trigger: {
                    global: "roundStart",
                  },
                  forced: true,
                  popup: false,
                  firstDo: true,
                  filter: function(event, player) {
                    return player.storage.zongchi3d8 == true;
                  },
                  content: function() {
                    var next = player.insertPhase();
                    event.next.remove(next);
                    trigger.next.push(next);
                    player.removeSkill("zongchi3d8_3");
                    delete player.storage.zongchi3d8;
                  },
                  sub: true,
                },
                "4": {
                  trigger: {
                    global: "phaseEnd"
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    player.storage.zongchi3d8 = true;
                    player.removeSkill("zongchi3d8_4");
                  }
                },
                skip: {
                  trigger: {
                    player: "phaseBefore",
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    trigger.cancel();
                    player.removeSkill("zongchi3d8_skip");
                  },
                  sub: true,
                },
                "skip2": {
                  trigger: {
                    player: "phaseEnd",
                  },
                  forced: true,
                  popup: false,
                  priority: 10,
                  content: function() {
                    player.addSkill("zongchi3d8_skip");
                    player.removeSkill("zongchi3d8_skip2");
                  },
                  sub: true,
                },
              },
            },
          },
          translate: {
            race3d8: "吧赛集锦",
            race_5: "三D五将",
            race_6: "三D六将",
            race_7: "三D七将",
            race_8: "三D八将",
            race_9: "三D九将",
            race_10: "三D十将",
            race_11: "三D十一将",
            race_12: "三D十二将",
            race_misc: "杂比赛",

            "3d8_caoxiu": "曹休",
            "3d8_wuzhi": "吴质",
            "3d8_jikang": "嵇康",
            "3d8sp_dongyun": "董允",
            "3d8_xujing": "许靖",
            "3d8_zhugezhan": "诸葛瞻",
            "3d8_buzhi": "步骘",
            "3d8_sunhao": "孙皓",
            "3d8_zhanglu": "张鲁",
            "3d8_yuantanyuanshang": "袁谭袁尚",

            "3d8_caomao": "曹髦",
            "3d8_wanglang": "王朗",
            "3d8_xinxianying": "辛宪英",
            "3d8_huojun": "霍峻",
            "3d8_huangquan": "黄权",
            "3d8_xianglang": "向朗",
            "3d8_sunliang": "孙亮",
            "3d8_lvfan": "吕范",
            "3d8_lukai": "陆凯",
            "3d8_chendeng": "陈登",
            "3d8_caojie": "曹节",

            "3d8_chentai": "陈泰",
            "3d8_liuye": "刘晔",
            "3d8_wuban": "吴班",
            "3d8_baosanniang": "鲍三娘",
            "3d8_kanze": "阚泽",
            "3d8_sunhuan": "孙桓",
            "3d8_liuqi": "刘琦",
            "3d8_zhangxiu": "张绣",
            "3d8_handang": "韩当",

            "3d8_guoxun": "郭循",
            "3d8_lvbu": "吕布",
            "3d8_simashi": "司马师",
            "3d8_jiangji": "蒋济",
            "3d8_dengzhi": "邓芝",
            "3d8_wangkanglvkai": "王伉吕凯",
            "3d8_sunjun": "孙峻",
            "3d8_panshu": "潘淑",
            "3d8_mengda": "孟达",

            "3d8_caoshuang": "曹爽",
            "3d8_dongzhao": "董昭",
            "3d8_donghe": "董和",
            "3d8_zongyu": "宗预",
            "3d8_sunshao": "孙韶",
            "3d8_puyangxing": "濮阳兴",
            "3d8_zhangmiao": "张邈",
            "3d8_chenggongying": "成公英",
            "3d8_shen_zhenji": "神甄姬",
            "3d8_shen_guojia": "神郭嘉",

            "3d8_zhaoang": "赵昂",
            "3d8_xuelingyun": "薛灵芸",
            "3d8_luoxian": "罗宪",
            "3d8_chenshou": "陈寿",
            "3d8_zhangti": "张悌",
            "3d8_zhugejing": "诸葛靓",
            "3d8_huangzu": "黄祖",
            "3d8_liuhong": "刘宏",

            "3d8_wangling": "王凌",
            "3d8_xiahouxuan": "夏侯玄",
            "3d8_qiaozhou": "谯周",
            "3d8_luotong": "骆统",
            "3d8_luji": "陆机",
            "3d8_zhangzhongjing": "张仲景",
            "3d8_liuchong": "刘宠",
            "3d8_hanfu": "韩馥",

            "3d8_qianzhao": "牵招",
            "3d8_lougui": "娄圭",
            "3d8_liaoli": "廖立",
            "3d8_huji": "胡济",
            "3d8_sunhe": "孙和",
            "3d8_zhouchu": "周处",
            "3d8_zhangkai": "张闿",
            "3d8_kebineng": "轲比能",

            "3d8_sunli": "孙礼",
            "3d8_weiguan": "卫瓘",
            "3d8_taohuang": "陶璜",
            "3d8_leitongwulan": "雷铜吴兰",
            "3d8_shen_machao": "神马超",


            xiansheng3d8: "先声",
            "xiansheng3d8_info": "一名其他角色的出牌阶段开始时，你可以对其使用一张【杀】。若此【杀】造成了伤害，该角色本回合不能使用【杀】。否则，该角色与你的距离视为１，直到回合结束。",
            lingyong3d8: "灵涌",
            lingyong3d81: "灵涌",
            lingyong3d82: "灵涌",
            lingyong3d83: "灵涌",
            lingyong3d84: "灵涌",
            "lingyong3d8_info": "一名角色跳过其一个阶段时，你可以判定并可以使用判定牌，若结果不为【杀】，你可以重复此流程。",
            xuxiao3d8: "虚孝",
            "xuxiao3d8_info": "每名角色的回合限一次，当一张黑色基本牌因弃置而置入弃牌堆时，你可以将此牌当【兵粮寸断】使用（无距离限制），然后目标角色摸两张牌。",
            qingxian3d8: "清弦",
            "qingxian3d8_info": "当你的一个区域内置入新的牌时，你可以弃置之，并可以视为使用一张无距离限制且不计入次数的基本牌。",
            juexiang3d8: "绝响",
            "juexiang3d8_info": "锁定技，你死亡时，可以声明一种花色，若如此做，所有角色无法使用或打出该花色的牌直到游戏结束。",
            biwei3d8: "弼违",
            "biwei3d8_info": "当一名体力值不小于你的角色成为【杀】的目标时，你可以令其将此【杀】的抵消方式改为将一张锦囊牌置于牌堆底。若如此做，结算完成后该角色摸一张牌。",
            juanlue3d8: "蠲略",
            "juanlue3d8_info": "你造成伤害的牌结算后，你可将其置于牌堆底；与你距离１以内的角色的准备阶段结束后，你可观看牌堆底的两张牌，然后令其开始其出牌阶段，并获得这些牌。",
            xuyu3d8: "虚誉",
            "xuyu3d8_info": "出牌阶段，你在本阶段使用的第一张牌结算后，你可以摸一张牌。若如此做，你在本阶段使用的第二张牌结算后，你弃置一张牌。",
            shijian3d8: "实荐",
            "shijian3d8_info": "一名其他角色的出牌阶段，该角色在本阶段使用的第三张牌结算后，你可以令其摸一张牌。若如此做，该角色在本阶段使用的第四张牌结算后，你摸一张牌。",
            ziwen3d8: "自问",
            "ziwen3d8_info": "锁定技，回合结束时，以下每满足一项，你摸一张牌：1.你本回合造成过伤害；2.你展示手牌中的一张【杀】；3.场上没有内奸。若均不满足，你失去1点体力。",
            weizhong3d8: "威重",
            "weizhong3d8_info": "你每于出牌阶段少使用一种类别的牌，便可于此阶段结束时选择一项：1、摸一张牌；2、本回合手牌上限+1。",
            jingjing3d8: "靖境",
            "jingjing3d8_info": "每当一名其他角色使用一张牌指定其他角色为目标时，你可以弃置一张相同类别的牌，然后令此牌无效。",
            jiuyan3d8: "酒宴",
            jiuyan3d8_buff: "酒宴",
            "jiuyan3d8_info": "你的回合内，所有角色可以将两张牌当做【酒】使用，且使用【酒】无次数限制。",
            zongying3d8: "纵饮",
            "zongying3d8_info": "出牌阶段，你可以使用一张【酒】，然后令一名其他角色选择一项：1.使用一张【酒】；2.令你视为对其使用一张【杀】，且“纵饮”无效直到回合结束。",
            jichi3d8: "极侈",
            "jichi3d8_info": "主公技，其他吴势力角色使用【酒】时，该角色可以令你摸一张牌。",
            mijiao3d8: "米教",
            "mijiao3d8_info": "每当你需要使用一张【闪】时，你可以令所有其他角色依次选择是否交给你一张牌，若没有角色选择是，视为你使用了一张【闪】。",
            yishe3d8: "义舍",
            "yishe3d8_info": "弃牌阶段结束时，你攻击范围内的其他角色可以依次获得此阶段内进入弃牌堆的牌，每有一名角色以此法获得其中的红色牌，你回复１点体力。",
            dikai3d8: "敌忾",
            "dikai3d8_info": "出牌阶段，你可以将至少两张手牌当【杀】使用，若以此法你使用的【杀】被目标角色的【闪】响应，你可以摸等量的牌。",
            zhengsi3d8: "争嗣",
            "zhengsi3d8_info": "锁定技，回合结束时，你须将手牌调整至2张。",

            taisi3d8: "太思",
            "taisi3d8_info": "你体力值发生变化的回合结束后，你可将弃牌堆里一张于本回合置入的牌交给一名角色，然后若该角色此回合对你造成过伤害，你摸两张牌。",
            quche3d8: "驱车",
            "quche3d8_info": "限定技，准备阶段，你可执行以下操作至多X次（X为你已损失的体力值）：将一张黑色牌当做【杀】使用；将一张红色牌交给其他角色。每执行一项，你本回合计算与其他角色的距离时便-1。",
            qianlong3d8: "潜龙",
            "qianlong3d8_info": "主公技，锁定技，其他魏势力角色于你的回合内死亡时，视为反贼身份。",
            lunzhan3d8: "论战",
            "lunzhan3d8_info": "出牌阶段限一次，你可以与一名其他角色拼点，若你赢，你回复1点体力；若你没赢，你失去1点体力，然后可以重复此流程。",
            boya3d8: "博雅",
            "boya3d8_info": "当其他角色于你的回合内失去最后的手牌时，其可以摸一张牌；当你于其他角色的回合内失去最后的手牌时，你可以摸两张牌。",
            dongcha3d8: "洞察",
            "dongcha3d8_info": "其他角色的回合开始时，若你有手牌，你可以令其与你依次将一张手牌扣置于你的武将牌上；则于此回合结束时，你获得你武将牌上的其中一张牌，该角色获得另一张。",
            zhijie3d8: "智解",
            "zhijie3d8_info": "你可以将你武将牌上相同颜色的两张牌当【闪】使用；你可以将你武将牌上不同颜色的两张牌当【无懈可击】使用。",
            gushou3d8: "孤守",
            "gushou3d8_info": "当你使用的基本牌结算后，你可展示所有手牌。若其中没有同名牌，你摸一张牌。",
            tandi3d8: "探敌",
            "tandi3d8_info": "你可以跳过摸牌或出牌阶段，并弃置一名其他角色的一张牌；若你令目标角色将此牌收回手牌，你仍执行该阶段。",
            qiahua3d8: "洽化",
            "qiahua3d8_info": "其他角色的回合开始时，你可以亮出X张手牌，则本回合其获得技能“恂恂”（X为其当前体力值）。",
            fusi3d8: "腹笥",
            "fusi3d8_info": "锁定技，你亮出的牌不计入手牌上限；若你的手牌均亮出，其他角色能使用你的手牌，且若此时处于你的回合，其他角色使用的牌只能为你的手牌。",
            fusi3d8_use: "腹笥",
            fusi3d8_response: "腹笥",
            tuoji3d8: "拓籍",
            "tuoji3d8_info": "若其他角色使用了你亮出的牌，结算后你可以摸两张牌。",
            diedang3d8: "跌宕",
            "diedang3d8_info": "出牌阶段限一次，你可以摸三张牌，弃一张牌。若如此做，交换描述中的“摸”与“弃”。",
            anliu3d8: "暗流",
            "anliu3d8_info": "结束阶段开始时，你可以与一名其他角色依次选择一张手牌，交换之。若颜色相同，你可以展示之并执行：红色，你回复1点体力。黑色，其摸两张牌。",
            kewu3d8: "克务",
            "kewu3d8_info": "额定回合的出牌阶段结束时，若你于此阶段每个类别仅使用至多一张牌，你可以结束此回合；若你于此阶段每个类别都使用至少一张牌，你可以在此回合结束后进行一个额外回合。",
            jingxuan3d8: "经玄",
            "jingxuan3d8_info": "出牌阶段，每当你使用一张牌时，你可以亮出牌堆顶牌，若两张牌类型相同，你可以重铸一张手牌。",
            kenjian3d8: "恳谏",
            "kenjian3d8_info": "每当一张装备牌进入弃牌堆时，若本回合没有与之相同类型的装备牌进入过弃牌堆，你可以将之置于当前回合角色的装备区。",
            jianni3d8: "间逆",
            "jianni3d8_info": "出牌阶段限一次，你可以选择攻击范围内含有你的一名角色区域内的一张牌，令其将此牌当【杀】对你使用，你可以为此【杀】额外指定一个目标。",
            yiluan3d8: "易乱",
            "yiluan3d8_info": "当你成为【杀】的目标时，你可以观看使用者的手牌。若如此做，你选择其一张牌并弃置之，再令其摸一张牌。",
            tianzuo3d8: "天祚",
            "tianzuo3d8_info": "弃牌阶段开始时，你可以摸一至两张牌，然后在本阶段结束时，所有体力少于X的角色各回复1点体力（X为你本阶段的弃牌数）。",
            dixi3d8: "抵玺",
            "dixi3d8_info": "弃牌阶段结束时，你可以令一名其他角色获得你于本阶段弃置的所有牌，然后技能“天祚”对其无效，且“抵玺”无效直到该角色死亡。",

            jieye3d8: "诘谒",
            "jieye3d8_info": "若你的武将牌上没有牌，你可以将一张手牌正面朝上置于你的武将牌上，视为你使用了一张【闪】；若你的武将牌上有牌，你可以收回此牌，视为你使用了一张【杀】。",
            "jieye3d82": "诘谒",
            chashi3d8: "察势",
            "chashi3d8_info": "一名其他角色的出牌阶段开始时，你可以展示一张手牌。若如此做，该角色于此阶段使用第一张牌时，若与你展示的牌花色相同，其摸一张牌。",
            qice3d8: "齐策",
            "qice3d8_info": "准备阶段或结束阶段，你可以摸两张牌。若如此做，此回合结束时，若你未于此回合内使用过锦囊牌，你失去“齐策”。",
            youzhen3d8: "诱阵",
            "youzhen3d8_info": "出牌阶段限一次，你可以令一名有牌的其他角色选择弃置至少一张牌，然后你可以弃置任意张牌。若你的弃牌数小于其，视为其对你使用一张【杀】；若你的弃牌数大于其，视为你对其使用一张【杀】（此【杀】不计入出牌阶段使用次数的限制）。",
            zhilian3d8: "枝连",
            "zhilian3d8_info": "一名角色的回合结束时，若本回合仅有两名角色使用过牌，你可以选择一项：令其各摸一张牌；或各弃一张牌，然后若这两名角色中包含你，你获得本回合进入弃牌区的所有【杀】。",
            jijian3d8: "赍剑",
            "jijian3d8_info": "出牌阶段限一次，你可以展示一名男性角色一张手牌，然后若此牌可以使用，你可以交给其一张装备牌或【杀】，视为其使用此牌。",
            huikuo3d8: "恢廓",
            "huikuo3d8_info": "当你需要使用一张【无懈可击】时，你可将至少一张手牌当作【无懈可击】使用，使你的手牌数为全场最少之一。",
            linrun3d8: "霖润",
            "linrun3d8_info": "全场体力值最少之一的角色成为【杀】的目标时，你可替该角色使用【闪】。若你未于此时机使用【闪】，你可以令该角色摸一张牌。",
            linrun3d8_init: "霖润",
            renxian3d8: "任险",
            "renxian3d8_info": "出牌阶段结束时，你可以令一名角色将一至两张牌置于牌堆顶。若其以此法置于牌堆顶的牌为两张，其可以选择一项：1.视为使用一张【杀】；2.回复1点体力。",
            chouti3d8: "抽梯",
            "chouti3d8_info": "出牌阶段，若没有角色因你拥有“困挟”，你可以交给一名其他角色一张牌，令其获得“困挟”。",
            kunxie3d8: "困挟",
            "kunxie3d8_info": "①锁定技，若你的手牌数等于手牌上限，你不能使用牌。②出牌阶段，你可以将一张锦囊牌交给令你获得“困挟”的角色，然后失去“困挟”。",
            zonghuo3d8: "宗祸",
            "zonghuo3d8_info": "当你失去一张手牌后，你可以令当前回合角色的手牌上限于本回合+1或-1。",
            baiyou3d8: "败诱",
            "baiyou3d8_info": "结束阶段，你可以展示所有手牌，若其中没有【杀】，你摸两张牌或回复一点体力，且直到你下回合开始时，你在所有角色攻击范围内。",
            fandi3d8: "反镝",
            "fandi3d8_info": "限定技，出牌阶段，你可以令所有有手牌的其他角色展示一张手牌，然后你可以指定一种颜色，令展示牌为此颜色的角色摸两张牌，为另一种颜色的角色弃置两张牌。",
            jiefan3d8: "解烦",
            "jiefan3d8_info": "你可以废弃一个装备区，视为使用了一张基本牌。以此法失去装备牌时，你摸两张牌。",
            gongqi3d8: "弓骑",
            "gongqi3d8_info": "锁定技，你和其他角色计算距离-X，X为你废弃装备区的数量。",

            qianfu3d8: "潜伏",
            "qianfu3d8_info": "锁定技，准备阶段开始时，若你的体力值或手牌数为1，你摸三张牌，然后结束当前回合。",
            zhuci3d8: "诛刺",
            "zhuci3d8_info": "其他角色的弃牌阶段开始时，你可以令其选择超出手牌上限的手牌，然后你可以使用一张牌：此牌结算完毕前，该角色不能使用或打出未以此法选择的牌；此牌结算完毕后，该角色弃置所选择的牌；若你以此法使其他角色的手牌数或体力值发生变化，本轮不可再次发动“诛刺”。",
            pimi3d8: "披靡",
            "pimi3d8_info": "每轮限一次，你使用【杀】/【决斗】造成伤害后，你为伤害来源的【决斗】/【杀】对其他角色造成的伤害+1，直到你的下一回合开始。",
            pimi3d8_buff_juedou: "披靡",
            pimi3d8_buff_sha: "披靡",
            baonu3d8: "暴怒",
            "baonu3d8_info": "你可以将所有手牌当【杀】或【决斗】使用。",
            baonu3d8_sha: "暴怒·杀",
            baonu3d8_juedou: "暴怒·决斗",
            tongshe3d8: "统摄",
            "tongshe3d8_info": "当一名角色成为你使用牌的唯一目标后，若其有牌，你可以取消之并令该角色选择是否令你获得其一张牌；当你使用牌指定一名角色为目标后，你对其造成X点伤害（X为其于此阶段内以此法选择否的次数）。",
            shenshi3d8: "审时",
            "shenshi3d8_info": "当你使用基本牌或非延时类锦囊牌时，可以移出至少一张可以使用的手牌/弃置至少一张不能使用的手牌，为此牌额外或少选择等量目标；回合结束时，你获得以此法移出的牌。",
            shenshi3d82: "审时",
            bigong3d8: "逼宫",
            "bigong3d8_info": "限定技，当你使用的一张牌选择了多于一名角色为目标时，你可以令一名目标角色选择一项：1、此牌只对其生效且连续结算X次（X为该牌的目标数）。2、失去所有技能。",
            ximeng3d8: "系盟",
            "ximeng3d8_info": "每轮开始时，你可以指定一名其他角色，其于本轮内视为拥有“和合”。",
            shiduan3d8: "识断",
            shiduan3d8_buff1: "识断",
            shiduan3d8_buff2: "识断",
            "shiduan3d8_info": "转换技，出牌阶段限一次，你可以令一名角色于其下个出牌阶段内使用【杀】的次数上限、使用以“出牌阶段限一次”开始的技能次数上限分别：①+1、-1。②-1、+1。",
            hehe3d8: "和合",
            "hehe3d8_info": "锁定技，当你/令你获得“系盟”的角色发动非锁定技时，令你获得“系盟”的角色/你摸一张牌。",
            bingjian3d8: "并肩",
            "bingjian3d8_info": "若你的手牌数或体力值为2：①你可以将一张牌当【杀】或【闪】使用或打出。每回合限一次。②你可以将两张牌当【杀】或【闪】使用或打出，然后你可以摸一张牌或移动场上的一张牌。每回合限一次。",
            bingjian3d8_one_sha: "并肩",
            bingjian3d8_one_shan: "并肩",
            bingjian3d8_two_sha: "并肩",
            bingjian3d8_two_shan: "并肩",
            shanquan3d8: "擅权",
            "shanquan3d8_info": "出牌阶段限一次，你可以选择一项：1、将场上的一张装备牌移动到你的装备区，然后弃置等同于你装备区里牌数的牌；2、对一名装备区里没有牌的角色造成1点伤害。",
            xiongyi3d8: "凶溢",
            "xiongyi3d8_info": "锁定技，你造成过伤害的回合内，跳过你的弃牌阶段；你每杀死一名角色，你的手牌上限便-1。",
            dujuan3d8: "妒娟",
            "dujuan3d8_info": "出牌阶段，你可以令你不为0的手牌上限于本回合内-1，令一名角色弃置牌至X张（X为其手牌上限）。",
            tuchou3d8: "图愁",
            "tuchou3d8_info": "锁定技，若你的体力与手牌均不为全场最多，攻击范围内含有你的其他角色回复1点体力时，你回复1点体力。",
            humou3d8: "狐谋",
            humou3d8_players: "狐谋",
            "humou3d8_info": "转换技，出牌阶段，你可以弃置一张黑色牌：①令一名手牌不少于你的角色摸一张牌;②观看一名手牌多于你的角色的手牌并可以使用其中一张;③视为对所有成为过“狐谋”目标的其他角色使用一张【万箭齐发】。",
            xuanshi3d8: "旋势",
            "xuanshi3d8_info": "当你受到伤害后，你可以选择一项：1.转换“狐谋”；2.失去“旋势”并删除“狐谋”的一个状态。",

            zhuanshe3d8: "专摄",
            "zhuanshe3d8_info": "其他角色的出牌阶段开始时，你可以将一张手牌正面朝上交给该角色，则当其在此回合内：使用与之名称相同的基本牌或普通锦囊牌时，你可额外（无距离限制）为之选择一个目标；未使用与之名称相同的牌，你可在回合结束时对其造成1点伤害。",
            "zhuanshe3d82": "专摄",
            "zhuanshe3d82_info": "",
            "zhuanshe3d83": "专摄",
            "zhuanshe3d83_info": "",
            "zhuanshe3d84": "专摄",
            "zhuanshe3d84_info": "",
            weiqiu3d8: "危秋",
            "weiqiu3d8_info": "锁定技，一名角色回复体力前，若你没有手牌，防止之然后你摸一张牌。",
            xianshi3d8: "先识",
            "xianshi3d8_info": "一名角色的回合开始时，你可以观看牌堆顶的三张牌（若你上轮发动“先识”没有角色获得牌，则翻倍），然后执行以下本轮未执行过的一项：展示其中任意数量相同颜色的牌，其获得之；将其中任意数量的牌置入弃牌堆。",
            "zaowang3d8_fan": "造王",
            zaowang3d8: "造王",
            "zaowang3d8_info": "限定技，出牌阶段，你可以令一名非主公的其他角色加1点体力上限、回复1点体力并摸三张牌，然后亮出其身份牌。若其为：忠臣，其与主公交换身份牌；反贼，当其死亡时，主忠方获胜。",
            shijiand3d8: "示俭",
            "shijiand3d8_info": "转换技，当一张①基本牌②装备牌③锦囊牌不因使用而置入弃牌堆时，你可以令一名非当前回合角色获得此牌，或令当前回合角色交给你一张牌。",
            zhengfeng3d8: "整风",
            "zhengfeng3d8_info": "出牌阶段限一次，你可以观看一名手牌不少于你的角色的手牌，然后你可以将你与其共计三张不同类别的手牌依次置于武将牌上后获得原“整风”牌。",
            tanli3d8: "探骊",
            "tanli3d8_info": "其他角色使用的装备牌结算后，你可以使用一张手牌，于此牌结算后选择一项：1、你摸一张牌，令其弃置该装备牌；2、其摸一张牌，你将该装备牌置入另一名角色的装备区。",
            dengjing3d8: "等竞",
            "dengjing3d8_info": "锁定技，你没有牌的装备栏视为装备着场上牌唯一最多的其他角色装备区里对应子类别的牌。",
            wenbing3d8: "稳兵",
            "wenbing3d8_info": "结束阶段，你可以将手牌调整至X张，若你没有以此法摸牌，X+1（X初始为2)；你可以将X当体力回复或扣减，且最终值不得小于0。",
            sili3d8: "肆立",
            "sili3d8_info": "每轮限一次，当其他角色受到伤害后，你可以指定受伤的另一名角色，若下一次受到伤害的角色不为你指定的角色，其回复1点体力。",
            "sili3d82": "肆立",
            "sili3d82_info": "",
            "sili3d83": "肆立",
            "sili3d83_info": "",
            xintu3d8: "辛土",
            "xintu3d8_info": "锁定技，摸牌阶段开始时，你展示牌堆顶四张牌并依次使用之（无法使用则不使用），然后你以此法使用的牌数：不小于X，你弃置装备区里一张牌；大于X，你结束摸牌阶段（X为你的体力值）。",
            xiaxing3d8: "侠行",
            "xiaxing3d8_info": "每轮限一次，一名角色处于濒死状态时/其回合开始时，你可以将一张牌置于牌堆顶，视为其使用一张【桃】/【酒】。若如此做，当你于下次使用牌之前需要使用一张【杀】或【闪】时，你可以视为使用之。",
            pingxi3d8: "平西",
            "pingxi3d8_info": "出牌阶段开始时，你可以重铸或使用一张【杀】，然后指定一名其他角色，令其执行相同的操作，否则你视为执行另一项。",
            wangzhi3d8: "望志",
            "wangzhi3d82": "望志",
            "wangzhi3d83": "望志",
            "wangzhi3d8_info": "当你获得牌后，你可以将其中一张♠牌置于你的武将牌上；你可以将所有的“望志”牌当一张【杀】或【闪】使用或打出，然后摸等量的牌。",
            miaoxing3d8: "淼形",
            "miaoxing3d8_info": "锁定技，分发起始手牌时，共发你三份起始手牌，你将其中两份移出游戏，称为“水相”；摸牌阶段结束时，你须将至少一份“水相”调整至手牌数。",
            miaoxing3d81: "水相",
            miaoxing3d82: "水相",
            miaoxing3d8_draw: "淼形",
            fushi3d8: "浮世",
            "fushi3d8_info": "每名角色的回合限一次，当你使用或打出的基本牌结算后，你可以用所有手牌交换一份“水相”，然后你可以指定一名男性角色，其可以用所有手牌交换其指定的一份“水相”。",
            fujv13d8: "拂局",
            "fujv13d8_info": "锁定技，其他角色的回合结束时，你恢复装备区域数/体力值至体力上限/手牌数。",
            fujv23d8: "浮遽",
            "fujv23d8_info": "锁定技，你受到的伤害均视为体力流失；你失去装备时废除对应的装备栏；你回合结束时，扣减你的体力上限至体力值。",
            fujv33d8: "复炬",
            "fujv33d8_info": "锁定技，你执行后一项时，需令一名其他角色执行前一项：弃置一张牌、失去一点体力、废除一个装备栏、扣减一点体力上限、死亡。",

            fenji3d8: "奋计",
            "fenji3d8_info": "摸牌/弃牌阶段开始时，你可以视为使用一张未以此法使用过的普通锦囊牌，然后将此阶段摸牌/弃牌数改为该牌造成伤害值/目标数。",
            "fenji3d8_draw": "奋计",
            "fenji3d8_draw_info": "",
            "fenji3d81": "奋计",
            "fenji3d81_info": "",
            "fenji3d82": "奋计",
            "fenji3d82_info": "",
            "fenji3d8_discard": "奋计",
            "fenji3d8_discard_info": "",
            lianer3d8: "涟洏",
            "lianer3d8_info": "当你使用红色牌后，你可以获得之，然后你只能使用点数小于此牌的牌直到回合结束。",
            anzhi3d8: "暗织",
            "anzhi3d8_info": "一名角色的回合开始时，若最近进入并在弃牌堆的牌包含黑色，你可以指定一名角色，此回合其第一次成为黑色牌的目标时，此牌对其无效。",
            shilie3d8: "示烈",
            "shilie3d8_info": "每回合限一次，当你需要使用一张【杀】或【闪】时，你可以明置任意数量点数之和大于或等于X的手牌，视为使用之。若为等于，你摸与此次明置牌张数等量的牌（X为你与当前回合角色的体力值之和）。",
            zhishuc3d8: "治书",
            "zhishuc3d8_info": "当你于出牌阶段使用有花色的牌指定目标后，你可以摸一张牌并声明一名目标角色的势力（需与此阶段声明的花色与势力均不同），此阶段内该花色的牌仅能指定该势力角色、该势力角色仅能成为该花色的牌的目标。",
            zhishuc3d8_mark: "治书",
            xunlu3d8: "寻录",
            "xunlu3d8_info": "回合结束时，你可以展示一张武将牌，若你本回合发动“治书”声明过该势力且弃牌堆里有对应花色的牌，你获得其中一张牌，否则你执行一个额外的出牌阶段。",
            nishi3d8: "逆势",
            "nishi3d8_info": "锁定技，准备阶段开始时，你须与手牌少于你的一名其他角色交换手牌。若你为手牌最少的角色，你须先将手牌摸至比手牌数最少的其他角色多一张牌。",
            fujiang3d8: "覆江",
            "fujiang3d8_info": "其他角色获得你的牌时，若其装备区里：有牌，你可以弃置其中一张牌；没有牌，你可以对该角色造成1点伤害。",
            sansi3d8: "三思",
            "sansi3d8_info": "转换技，出牌阶段限一次，你可以重铸①两张牌②三种类别的牌③四种花色的牌，令一名角色摸三张牌。",
            jiezhong3d8: "竭忠",
            "jiezhong3d8_info": "每轮限一次，其他角色进入濒死时，你可以令其将体力值回复至1点，然后你转换“三思”的状态；然后若“三思”状态：为①，你失去1点体力；为③，重置此技能。",
            tunshou3d8: "屯守",
            "tunshou3d8_info": "出牌阶段开始时，你可以摸两张牌，然后你本回合使用的牌对其他角色的效果改为将目标角色的一张牌扣置于你的武将牌上；若你使用的牌点数大于你此阶段使用的上一张牌，你将武将牌上的一张牌翻面；回合结束时，你获得武将牌上正面向上的所有牌，将其余牌置入弃牌堆。",
            tunshou3d82: "屯守",
            tunshou3d83: "屯守",
            shixing3d8: "失兴",
            "shixing3d8_info": "锁定技，若有存活的女性角色，你视为拥有“享乐”；若当前回合没有锦囊牌被使用，你视为拥有“酒诗”；若你没有上述技能，你视为拥有“制衡”。",
            danggu3d8: "党锢",
            "danggu3d8_info": "回合结束时，你可以横置至多X名角色（X为群势力角色数）；其他角色的弃牌阶段，若其处于“连环状态”，其装备区里的牌视为手牌。",

            zhangchuan3d8: "障川",
            "zhangchuan3d8_info": "若场上一种颜色的牌多于其他颜色，你可以将一张该颜色的牌当【无懈可击】或【闪】使用或打出；你可以代替手牌少于你的角色使用或打出【闪】。",
            xingbian3d8: "星变",
            "xingbian3d8_info": "限定技，回合结束后，你可以展示手牌并将“障川”不能转化的牌置于武将牌上（需不少于其它牌），失去“障川”并获得“回澜”，然后若你没有手牌，你获得一个额外回合。",
            huilan3d8: "回澜",
            "huilan3d8_info": "你可以将“星变”牌当【无中生有】或【杀】使用或打出；你可以对手牌不多于“星变”牌的其他角色使用【无中生有】或不计入次数限制的【杀】。",
            langhuai3d8: "朗怀",
            "langhuai3d8_info": "转换技，摸牌阶段，你可以展示手牌（无牌则不展示）并改为摸其中①包含②缺少花色数的牌。",
            langhuai3d8_forced: "朗怀",
            "langhuai3d8_forced_info": "转换技，摸牌阶段，你须展示手牌（无牌则不展示）并改为摸其中①包含②缺少花色数的牌。",
            xuanlun3d8: "玄论",
            "xuanlun3d8_info": "当你受到伤害后，你可以摸四张牌；你发动此技能的回合结束时，须选择一项：将四张牌以任意顺序置于牌堆底（不足则全置）；或令“朗怀”和“玄论”改为“锁定技”，然后删除该选项。",
            xuanlun3d8_forced: "玄论",
            "xuanlun3d8_forced_info": "当你受到伤害后，你摸四张牌；你发动此技能的回合结束时，须将四张牌以任意顺序置于牌堆底（不足则全置）。",
            chouguo3d8: "仇国",
            "chouguo3d8_info": "锁定技，一名角色使用【杀】时，若你的手牌为全场最少，你摸一张牌，然后若该角色为你且体力为全场最少，你令此【杀】无效并回复1点体力。",
            jianxiang3d8: "谏降",
            "jianxiang3d8_info": "回合结束时，若你于本回合回复过体力或使用过装备牌，你可以令一名其他角色选择一项：视为拥有“仇国”直到你回合开始；视为拥有“黩武”直到其回合结束。",
            huili3d8: "惠理",
            "huili3d8_info": "锁定技，每轮开始时，你将以下标记补至一枚：“民”～基本牌，“政”～锦囊牌，“军”～装备牌；当你成为牌的目标后，你弃置对应的上述标记；当你弃置标记时，你令一名角色摸一张牌。",
            zhishu3d8: "直疏",
            "zhishu3d8_info": "出牌阶段，若你有“惠理”标记，你可以令一名有手牌的其他角色使用与之对应的牌。若其使用牌，你弃置对应标记，其回复1点体力，否则你须如此做，或令本阶段“直疏”失效。",
            "zhishu3d82": "直疏",
            "zhishu3d82_info": "",
            bianwang3d8: "辩亡",
            "bianwang3d8_info": "转换技，一回合限一次，一名角色①受到伤害或失去体力前②回复体力前，你可以令之于本回合结束时结算，若此时已无法执行，你能令另一名角色结算之。",
            "bianwang3d82": "辩亡",
            "bianwang3d82_info": "",
            "bianwang3d83": "辩亡",
            "bianwang3d83_info": "",
            kuangnan3d8: "匡难",
            "kuangnan3d8_info": "一名角色的回合开始时，你可以令其攻击范围内一名已受伤的角色回复1点体力，且你不能如此做直至后者造成或前者受到伤害；若你于该回复体力/伤害事件中能发动“辩亡”，基数+1。",
            "kuangnan3d82": "匡难",
            "kuangnan3d82_info": "",
            "kuangnan3d83": "匡难",
            "kuangnan3d83_info": "",
            "kuangnan3d84": "匡难",
            "kuangnan3d84_info": "",
            quhan3d8: "祛寒",
            "quhan3d8_info": "出牌阶段，你可以展示一名其他角色一至X张手牌，你需弃置一张为其中一张牌花色的牌令其回复1点体力；否则本阶段“祛寒”失效（X为其已损失的体力值）。",
            changtang3d8: "敞堂",
            "changtang3d8_info": "结束阶段，你可以选择除你以外手牌最少的一名其他角色，然后你展示手牌，从该角色开始，每名其他角色能交给你一张与你手牌花色均不同的牌，摸两张牌。",
            jinggou3d8: "精彀",
            "jinggou3d8_info": "锁定技，你使用的武器牌结算后，若你的攻击范围为全场最大或最小（或之一），你须对一名角色造成1点伤害。",
            moyan3d8: "末焱",
            "moyan3d8_info": "每轮开始时，你可以亮出牌堆顶的三张牌，令一名角色选择并获得其中至少一张牌；本轮其受到伤害时，若其手牌数不大于X，此伤害+X（X为其此次得到的牌数）。",
            moyan3d8_buff: "末焱",
            "moyan3d8_buff_info": "",
            yijue3d8: "疑决",
            "yijue3d8_info": "锁定技，回合开始时，你亮出牌堆顶的X张牌（X为你的体力值）。你能使用其中一张牌，若使用该牌时你令所有目标角色依次选择其中一张牌并获得之，该牌结算后你能重复此流程。结算完成后，若仍有“疑决”牌，你失去1点体力。",

            yuanzhen3d8: "远振",
            "yuanzhen3d8_info": "锁定技，你使用牌指定与你距离不为1的其他角色为唯一的目标后，你令其选择一项：1. 弃置一张牌；2. 令你摸一张牌。",
            zhirong3d8: "制戎",
            "zhirong3d8_info": "出牌阶段开始时，你可将一名角色场上的一张装备牌置入另一名角色的装备区，然后前者视为对后者使用【过河拆桥】。",
            ningbei3d8: "凝备",
            "ningbei3d8_info": "结束阶段，你可将一张黑色非装备牌置入防具栏，令一名无“坔城”角色获得“坔城”；若其不为你，你摸两张牌。",
            jince3d8: "尽策",
            "jince3d8_info": "锁定技，轮次结束时，体力值唯一最大的角色选择你区域里的至多两张牌，然后你均使用/收回/重铸这些牌。",
            dicheng3d8: "坔城",
            "dicheng3d8_info": "锁定技，你受到黑色【杀】造成伤害时，若令你获得“坔城”的角色防具栏有“凝备”牌，此伤害-1；否则，所有以此法获得“坔城”的角色失去“坔城”。",
            fenlun3d8: "忿论",
            "fenlun3d8_info": "一名其他角色的结束阶段开始时，若其于此回合内使用的牌曾被牌响应，你可与包括该角色在内的至多两名角色同时拼点。",
            qicai3d8: "弃才",
            "qicai3d8_info": "你于回合外失去所有手牌后，你可从牌堆底摸（3-X）张牌（X为你此轮拼点输的次数）。你不以此法获得牌后，令X减至0。",
            jianjun3d8: "渐军",
            "jianjun3d8_info": "你/其他角色使用牌指定其他角色/你为目标时，你可选择这些角色区域里的共计至多三张牌，然后依次令这些角色：弃置其中明置的手牌；明置其中暗置的手牌；将其中场上的牌收回手牌且本回合不能使用这些牌。",
            jianjun3d8_mark: "渐军",
            mingye3d8: "命也",
            "mingye3d8_info": "锁定技，回合内外每轮各限一次，你使用基本牌或普通锦囊牌时，你取消此牌，且令之不计限制次数，然后摸两张牌。若如此做，若你非因“党乎”获得此技能，则你可弃置一张红桃牌，回复1点体力；否则你可令使你获得“命也”的角色获得被取消的牌。",
            mingye3d8_get: "命也",
            "mingye3d8_get_info": "锁定技，回合内外每轮各限一次，你使用基本牌或普通锦囊牌时，你取消此牌，且令之不计限制次数，然后摸两张牌。你可令使你获得“命也”的角色获得被取消的牌。",
            xiaheng3d8: "侠横",
            "xiaheng3d8_info": "锁定技，出牌阶段开始时，你弃置一名角色两张牌（不足则全弃），再对一名角色造成1点伤害。【若两名角色，均不为你，你减1点体力上限；为同一名角色，你失去1点体力；】然后若以此法选择包括你在内三名不同的角色，你删除【】中的内容。",
            xiaheng_gai_3d8: "侠横",
            "xiaheng_gai_3d8_info": "锁定技，出牌阶段开始时，你弃置一名角色两张牌（不足则全弃），再对一名角色造成1点伤害。",
            xiaheng3d8_players: "侠横",
            danghu3d8: "党乎",
            "danghu3d8_info": "每轮限一次，你的体力值改变后，你可令一名其他角色于本轮中拥有“命也”。",
            jiexing3d8: "劫行",
            "jiexing3d8_info": "限定技，其他角色回复体力时，你可改为你回复等量体力；一张装备区因使用而置入其他角色的装备区时，你可改为置入你的装备区。你不以此法回复体力后，或装备区不以此法置入你的装备区后，重置技能次数。",
            bailei3d8: "拜泪",
            "bailei3d8_info": "轮次开始时，你可杀死体力值唯一为1的角色，或对体力唯一最多的角色造成2点伤害。",
            xiaoxing3d8: "枭行",
            "xiaoxing3d8_info": "锁定技，你的攻击范围和手牌上限+3；你进入濒死状态时，若轮次数大于一，且伤害来源装备了武器牌，其可废除其武器栏，令你失去“枭行”。",
            langzhi3d8: "狼志",
            "langzhi3d8_info": "结束阶段，你可令你攻击范围内的所有角色各展示一张牌，你选择其中任意张牌并选择一项：1.用等量牌替换这些牌；2.获得这些牌，失去“狼志”。",
            fuyi3d8: "附义",
            "fuyi3d8_info": "主公技，其他群势力角色杀死角色时，若你已失去“枭行”或“狼志”，其可改为令你获得其中一或两个；若为两个，你摸三张牌，失去“附义”。",

            leili3d8: "雷厉",
            "leili3d8_info": "出牌阶段限一次，你可以横置一名其他角色并视为对其使用一张雷【杀】，若如此做，你横置。",
            fengxing3d8: "风行",
            "fengxing3d8_info": "当你的武将牌横置时，你可以移动场上一张牌；当你失去一次装备区里的牌时，你可以重置武将牌，或摸一张牌。",
            dijiang3d8: "涤疆",
            "dijiang3d8_info": "每轮限一次，当一名角色使用【杀】造成伤害后，你可以对其攻击范围外的一名角色造成1点伤害；你使用梅花牌后，重置此技能。",
            "dijiang3d82": "涤疆",
            "dijiang3d82_info": "",
            yuwang3d8: "玉望",
            "yuwang3d8_info": "锁定技，其他角色进入濒死状态时，你加一点体力上限，然后你成为【桃】的额外目标直至此次濒死结算完毕，若你因此回复体力至上限，你失去此技能。",
            "yuwang3d82": "玉望",
            "yuwang3d82_info": "",
            "yuwang3d83": "玉望",
            "yuwang3d83_info": "",
            weizheng3d8: "维整",
            "weizheng3d8_info": "弃牌阶段开始时，若X不大于游戏人数，你可以选择X名目标并声明一张群体锦囊牌的牌名，视为你对这些角色使用此牌。然后你本回合手牌上限视为X（X为你本回合使用牌指定过的目标数之和）。",
            "weizheng3d82": "维整",
            "weizheng3d82_info": "",
            "weizheng3d83": "维整",
            "weizheng3d83_info": "",
            zhiduan3d8: "制断",
            "zhiduan3d8_info": "转换技，①你的回合外②你的回合内，你可以视为使用一张【无懈可击】。",
            haolie3d8: "豪烈",
            "haolie3d8_info": "转换技，①出牌阶段，你可弃置一名其他角色的一张手牌，若为基本牌，你视为对其使用一张【杀】。②当你失去牌后，你可弃置当前回合角色的一张牌。",
            hengxiao3d8: "横嚣",
            "hengxiao3d8_info": "锁定技，你的回合仅执行出牌阶段。出牌阶段开始时，你摸[4]张牌，出牌阶段结束时，你弃置所有手牌，若你于此出牌阶段使用过【杀】，你于此阶段结束后获得一个额外的出牌阶段且此回合[]内数字-1。",
            zongchi3d8: "纵驰",
            "zongchi3d8_info": "每轮开始时，你可以废除一个装备栏，然后获得以下一项效果直至本轮结束：1.你最先进行回合，且其他角色视为在你攻击范围内。2.你最后进行回合，且你视为在其他角色攻击范围外。",

          },
        };
        if (lib.device || lib.node) {
          for (var i in race3d8.character) {
            race3d8.character[i][4].push('ext:贴吧精品/image/' + i + '.jpg');
          }
        } else {
          for (var i in race3d8.character) {
            race3d8.character[i][4].push('db:extension-贴吧精品/image:' + i + '.jpg');
          }
        }
        return race3d8;
      });

      game.import('character', function() {
        var person3d8 = {
          name: 'person3d8',
          connect: true,
          characterSort: {
            person3d8: {
              yaoshi: ['3d8_sp_zhugeliang', '3d8_luxun', '3d8_zhouyu'],
              liushuixi: ['3d8_jushou', '3d8_dongbai', '3d8_zhongyao', '3d8_guyong', '3d8_gongsunyuan'],
              feizhi: ['3d8_dongyun', '3d8_guotufengji'],
              haohaizi: ["3d8_sunquan"],
              lapulasi: ["3d8_daqiao"],
              diy: ["diy_quezheng"],
            },
          },
          character: {
            "3d8_sp_zhugeliang": ["male", "shu", 3, ["nangce3d8", "ruliao3d8"],
              []
            ],
            "3d8_luxun": ["male", "wu", 3, ["duoshi3d8", "guanying3d8"],
              []
            ],
            "3d8_zhouyu": ["male", "wu", 3, ["qugu3d8", "liejiang3d8"],
              []
            ],
            "3d8_jushou": ["male", "qun", 3, ["zhongyan3d8", "shibei3d8"],
              []
            ],
            "3d8_dongbai": ["female", "qun", 3, ["yishi3d8", "zhulian3d8"],
              []
            ],
            "3d8_zhongyao": ["male", "wei", 3, ["kaizheng3d8", "huihao3d8"],
              []
            ],
            "3d8_guyong": ["male", "wu", 3, ["shenxing3d8", "bingyi3d8"],
              []
            ],
            "3d8_gongsunyuan": ["male", "qun", 4, ["sixing3d8"],
              []
            ],
            "3d8_dongyun": ["male", "shu", 3, ["zhunzhun3d8", "danbo3d8"],
              []
            ],
            "3d8_guotufengji": ["male", "qun", 3, ["kongshe3d8", "gouxian3d8"],
              []
            ],
            "3d8_sunquan": ["male", "wu", 4, ["zhiheng3d8"],
              []
            ],
            "3d8_daqiao": ["female", "wu", 3, ["zhuangcheng3d8", "buluo3d8"],
              []
            ],
            "diy_quezheng": ["male", "shu", 3, ["sujiediy", "moyidiy"],
              []
            ],
          },
          skill: {
            nangce3d8: {
              audio: "huoji",
              trigger: {
                player: "useCard",
              },
              filter: function(event, player) {
                return get.type(event.card) == 'trick';
              },
              check: function(event, player) {
                return get.attitude(player, _status.currentPhase) > 0;
              },
              content: function() {
                player.line(_status.currentPhase, 'green');
                _status.currentPhase.draw();
              },
              ai: {
                threaten: 1.4,
                noautowuxie: true,
              },
            },

            ruliao3d8: {
              group: ["ruliao3d8_shan", "ruliao3d8_wuxie"],
              subSkill: {
                shan: {
                  audio: "kanpo",
                  mod: {
                    aiValue: function(player, card, num) {
                      if (get.name(card) != 'shan' && get.color(card) != 'black') return;
                      var cards = player.getCards('hs', function(card) {
                        return get.name(card) == 'shan' || get.color(card) == 'black';
                      });
                      cards.sort(function(a, b) {
                        return (get.name(b) == 'shan' ? 1 : 2) - (get.name(a) == 'shan' ? 1 : 2);
                      });
                      var geti = function() {
                        if (cards.contains(card)) {
                          return cards.indexOf(card);
                        }
                        return cards.length;
                      };
                      if (get.name(card) == 'shan') return Math.min(num, [6, 4, 3][Math.min(geti(), 2)]) * 0.6;
                      return Math.max(num, [6.5, 4, 3][Math.min(geti(), 2)]);
                    },
                    aiUseful: function() {
                      return lib.skill.reqingguo.mod.aiValue.apply(this, arguments);
                    },
                  },
                  locked: false,
                  enable: ["chooseToRespond", "chooseToUse"],
                  filterCard: function(card) {
                    return get.color(card) == 'black';
                  },
                  position: "hes",
                  viewAs: {
                    name: "shan",
                  },
                  viewAsFilter: function(player) {
                    if (!player.countCards('hes', {
                        color: 'black'
                      })) return false;
                  },
                  prompt: "将一张黑色牌当闪打出",
                  check: function() {
                    return 1
                  },
                  ai: {
                    order: 2,
                    respondShan: true,
                    skillTagFilter: function(player) {
                      if (!player.countCards('hes', {
                          color: 'black'
                        })) return false;
                    },
                    effect: {
                      target: function(card, player, target, current) {
                        if (get.tag(card, 'respondShan') && current < 0) return 0.6
                      },
                    },
                    basic: {
                      useful: [7, 5.1, 2],
                      value: [7, 5.1, 2],
                    },
                    result: {
                      player: 1,
                    },
                  },
                },
                wuxie: {
                  mod: {
                    aiValue: function(player, card, num) {
                      if (get.name(card) != 'wuxie' && get.color(card) != 'black') return;
                      var cards = player.getCards('hs', function(card) {
                        return get.name(card) == 'wuxie' || get.color(card) == 'black';
                      });
                      cards.sort(function(a, b) {
                        return (get.name(b) == 'wuxie' ? 1 : 2) - (get.name(a) == 'wuxie' ? 1 : 2);
                      });
                      var geti = function() {
                        if (cards.contains(card)) {
                          return cards.indexOf(card);
                        }
                        return cards.length;
                      };
                      if (get.name(card) == 'wuxie') return Math.min(num, [6, 4, 3][Math.min(geti(), 2)]) * 0.6;
                      return Math.max(num, [6, 4, 3][Math.min(geti(), 2)]);
                    },
                    aiUseful: function() {
                      return lib.skill.rekanpo.mod.aiValue.apply(this, arguments);
                    },
                  },
                  locked: false,
                  position: "hes",
                  enable: "chooseToUse",
                  filterCard: function(card) {
                    return get.color(card) == 'black';
                  },
                  viewAsFilter: function(player) {
                    return player.countCards('hes', {
                      color: 'black'
                    }) > 0;
                  },
                  viewAs: {
                    name: "wuxie",
                  },
                  prompt: "将一张黑色牌当无懈可击使用",
                  check: function(card) {
                    return 7 - get.value(card)
                  },
                  ai: {
                    basic: {
                      useful: [6, 4, 3],
                      value: [6, 4, 3],
                    },
                    result: {
                      player: 1,
                    },
                    expose: 0.2,
                  },
                },
              },
            },

            duoshi3d8: {
              audio: "jlsg_dailao",
              enable: "phaseUse",
              usable: 1,
              filter: function(event, player) {
                if (player.countCards('he') == 0) {
                  return false;
                }
                return true;
              },
              content: function() {
                "step 0"
                var num1 = player.countCards('he');
                player.chooseCardTarget({
                  filterCard: function(card) {
                    event = event || _status.event;
                    if (typeof event != 'string') event = event.getParent().name;
                    var mod = game.checkMod(card, player, event, 'unchanged', 'cardDiscardable', player);
                    if (mod != 'unchanged') return mod;
                    return true;
                  },
                  position: 'he',
                  selectCard: [1, 3],
                  selectTarget: 1,
                  filterTarget: function(card, player, target) {
                    return true;
                  },
                  ai1: function(card) {
                    return 6 - get.value(card);
                  },
                  ai2: function(target) {
                    var s = 0;
                    if (player == target) {
                      if (target.hp == 1) return 5;
                      return 2;
                    } else if (get.attitude(player, target) > 0) {
                      if (target.hp == 1 || target.countCards('h') <= 1) {
                        if (target.hasJudge('lebu')) return -1;
                        return 4;
                      } else if (target.countCards('h') < target.hp) return 3;
                      return 1;
                    }
                    return -1;
                  },
                  prompt: '度势：弃置至多三张牌，然后令一名角色摸等量的牌',
                });
                "step 1"
                if (result.bool) {
                  player.discard(result.cards);
                  result.targets[0].draw(result.cards.length);
                }
              },
              ai: {
                order: 1,
                expose: 0.3,
                result: {
                  player: function(player, target) {
                    var cards = player.getCards('he');
                    var flag = 0;
                    for (var i = 0; i < cards.length; i++) {
                      var card = cards[i];
                      if (6 - get.value(card) > 0) flag = 1;
                    }
                    if (flag == 0) return -1;
                    return 1;
                  },
                },
                threaten: 1.2,
              },
            },

            guanying3d8: {
              audio: "jlsg_youdi",
              trigger: {
                player: "loseAfter",
              },
              frequent: true,
              filter: function(event, player) {
                return (!player.countCards('e') && event.es && event.es.length > 0) ||
                  (!player.countCards('h') && event.hs && event.hs.length > 0) ||
                  (!player.countCards('j') && event.js && event.js.length > 0);
              },
              content: function() {
                if (!player.countCards('e') && trigger.es && trigger.es.length > 0) player.draw();
                if (!player.countCards('h') && trigger.hs && trigger.hs.length > 0) player.draw();
                if (!player.countCards('j') && trigger.js && trigger.js.length > 0) player.draw();
              },
              ai: {
                expose: 0.7,
                threaten: 1.2,
                effect: {
                  target: function(card, player, target, current) {
                    if (get.type(card) == 'delay') return [1, 1];
                  },
                },
                noh: true,
                noe: true,
                skillTagFilter: function(player, tag) {
                  if (tag == 'noh') {
                    if (player.countCards('h') != 1) return false;
                  }
                  if (tag == 'noe') {
                    if (player.countCards('e') != 1) return false;
                  }
                },
              },
            },

            qugu3d8: {
              audio: "qinyin",
              trigger: {
                player: "phaseZhunbeiBegin",
              },
              frequent: true,
              filter: function(event, player) {
                return true;
              },
              content: function() {
                "step 0"
                player.chooseTarget('曲顾：令一名角色摸一张牌', function(card, player, target) {
                  return true;
                }).ai = function(target) {
                  if (player == target) {
                    if (target.hp == 1) return 5;
                    return 2;
                  } else if (get.attitude(player, target) > 0) {
                    if (target.hp == 1 || target.countCards('h') <= 1) {
                      if (target.hasJudge('lebu')) return -1;
                      return 4;
                    } else if (target.countCards('h') < target.hp) return 3;
                    return 1;
                  }
                  return -1;
                }
                "step 1"
                if (result.bool) {
                  player.line(result.targets[0], 'green');
                  result.targets[0].draw();
                }
              },
            },

            liejiang3d8: {
              audio: "yeyan",
              enable: "phaseUse",
              usable: 1,
              filter: function(event, player) {
                if (player.countCards('h') == 0) {
                  return false;
                }
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i] != player && players[i].countCards("h") > 0) return true;
                }
                return false;
              },
              content: function() {
                'step 0'
                player.chooseTarget(get.prompt2('liejiang3d8'), true, function(card, player, target) {
                  return target != player && target.countCards('h');
                }).set('ai', function(target) {
                  var att = get.attitude(_status.event.player, target);
                  if (att > 0) return -1;
                  if (att == 0) return 0.1;
                  return get.damageEffect(target, player, player, 'fire');
                });
                'step 1'
                if (result.bool) {
                  player.line(result.targets[0], 'red');
                  event.target = result.targets[0];
                  player.chooseCard('h', true).ai = function(card) {
                    return 20 - get.value(card);
                  };

                }
                'step 2'
                if (result.bool) {　　
                  event.cardp = result.cards[0];
                  event.target.chooseCard('h', true).ai = function(card) {
                    return 20 - get.value(card);
                  };
                }
                'step 3'
                if (result.bool) {
                  event.cardt = result.cards[0];
                  player.showCards(event.cardp);
                  event.target.showCards(event.cardt);
                }
                'step 4'
                player.$giveAuto(event.cardp, event.target);
                event.target.gain(event.cardp, player);
                event.target.give(event.cardt, player);
                'step 5'
                var suitp = get.suit(event.cardp);
                var suitt = get.suit(event.cardt);
                if (suitp != suitt) {
                  event.target.damage('fire', player);
                }
              },
              ai: {
                order: 1,
                expose: 0.6,
                threaten: 2,
                result: {
                  player: function(player, target) {
                    var cards = player.getCards('he');
                    var flag = 0;
                    for (var i = 0; i < cards.length; i++) {
                      var card = cards[i];
                      if (7 - get.value(card) > 0 && card.name != 'tao') flag = 1;
                    }
                    if (flag == 0) return -1;
                    return 1;
                  },
                },
              },
            },

            zhongyan3d8: {
              audio: "jianying",
              trigger: {
                player: "phaseUseBegin",
              },
              filter: function(event, player) {
                return true;
              },
              check: function(event, player) {
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (get.attitude(player, players[i]) <= 0) continue;
                  if (players[i] == player) continue;
                  var count = players[i].countCards("h");
                  if (player.hp >= 3) return true;
                  if (player.hp == 2) {
                    if (player.maxHp >= 3 && count + player.maxHp >= 5) return true;
                    if (player.maxHp == 2 && count + player.maxHp >= 6) return true;
                  }
                  if (player.hp == 1) {
                    if (player.maxHp >= 3 && count + player.maxHp >= 6) return true;
                    if (player.maxHp == 2 && count + player.maxHp >= 7) return true;
                    if (player.maxHp == 1 && count + player.maxHp >= 8) return true;
                  }
                }
                return false;
              },
              content: function() {
                "step 0"
                player.chooseTarget("忠言：选择一名其他角色", function(card, player, target) {
                  return player != target;
                }, false).ai = function(target) {
                  if (get.attitude(player, target) <= 0) return -1;
                  return target.countCards("h") + player.maxHp;
                }
                "step 1"
                if (result.bool) {
                  result.targets[0].draw(player.maxHp);
                  result.targets[0].showHandcards();
                  event.target = result.targets[0];
                }
                "step 2"
                if (event.target) {
                  var cards = event.target.getCards("h");
                  var suits = [];
                  for (var i = 0; i < cards.length; i++) {
                    if (!suits.contains(get.suit(cards[i]))) suits.add(get.suit(cards[i]));
                  }
                  if (suits.length < 4) player.loseHp();
                }

              },
              ai: {
                expose: 0.5,
                threaten: 2,
              },
            },

            shibei3d8: {
              audio: "shibei",
              trigger: {
                player: "damageBefore",
              },
              forced: true,
              content: function() {
                trigger.cancel();
                player.loseHp();
              },
              ai: {
                noDirectDamage: true,
              },
              group: ["shibei3d8_death"],
              subSkill: {
                death: {
                  audio: "shibei",
                  enable: "chooseToUse",
                  filter: function(event, player) {
                    if (event.type == 'dying') {
                      if (player != event.dying) return false;
                      return true;
                    }
                    return false;
                  },
                  content: function() {
                    'step 0'
                    player.loseMaxHp();
                    'step 1'
                    player.recover(player.maxHp - player.hp);
                  },
                  ai: {
                    order: 1,
                    skillTagFilter: function(player, arg, target) {
                      if (player.maxHp == 1) return false;
                    },
                    save: true,
                    result: {
                      player: function(player) {
                        if (player.maxHp == 1) return 1;
                        if (player.hp <= 0) return 10;
                      },
                    },
                  },
                },
              },

            },

            yishi3d8: {
              audio: "lianzhu",
              trigger: {
                player: "phaseJieshuBegin",
              },
              filter: function(event, player) {
                var count = 0;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i] == player) continue;
                  count = Math.max(players[i].hp, count);
                }
                if (count <= player.hp) return false;
                return true;
              },
              forced: true,
              content: function() {
                var count = 0;
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i] == player) continue;
                  count = Math.max(players[i].hp, count);
                }
                player.recover(count - player.hp);
                if (count > player.maxHp) player.draw();
              },
            },

            zhulian3d8: {
              audio: "lianzhu",
              trigger: {
                global: "gameStart",
              },
              forced: true,
              content: function() {
                if (!player.isLinked()) player.link();
              },
              ai: {
                result: {
                  player: function(player, target) {
                    return 1;
                  }
                }
              },
              group: ["zhulian3d8_link", "zhulian3d8_damage"],
              subSkill: {

                link: {
                  audio: "lianzhu",
                  trigger: {
                    player: "linkAfter",
                  },
                  filter: function(event, player) {
                    return !player.isLinked();
                  },
                  forced: true,
                  content: function() {
                    player.link();
                  },
                },
                damage: {
                  audio: "lianzhu",
                  trigger: {
                    player: "damageBegin",
                  },
                  forced: true,
                  content: function() {
                    var players = game.filterPlayer();
                    for (var i = 0; i < players.length; i++) {
                      if (players[i] == player) continue;
                      if (get.distance(player, players[i], 'attack') > 1) continue;
                      if (players[i].isLinked()) continue;
                      players[i].link();
                    }
                  },
                  ai: {
                    effect: {
                      target: function(card, player, target, current) {
                        if (card.name == 'tiesuo') return 'zerotarget';
                        if (get.tag(card, 'damage') && get.tag(card, 'natureDamage')) {
                          var players = game.filterPlayer();
                          var count = 0;
                          for (var i = 0; i < players.length; i++) {
                            if (players[i] == target) continue;
                            if (get.distance(target, players[i], 'attack') > 1) continue;
                            if (players[i].isLinked()) continue;
                            count += get.damageEffect(players[i], player, target);
                          }
                          return [1, count];
                        }
                      },
                    },
                  },
                },
              },
            },

            kaizheng3d8: {
              audio: "zuoding",
              trigger: {
                player: ["phaseDrawBegin", "phaseJudgeBegin", "phaseUseBegin", "phaseDiscardBegin"],
              },
              forced: true,
              filter: function(event, player) {
                return player.countCards("h") != player.maxHp;
              },
              content: function() {
                if (player.countCards("h") > player.maxHp) player.chooseToDiscard(player.countCards("h") - player.maxHp, true);
                else if (player.countCards("h") < player.maxHp) player.draw(player.maxHp - player.countCards("h"));
              },

            },

            huihao3d8: {
              audio: "huomo",
              trigger: {
                player: ["phaseJieshuBegin"],
              },
              forced: true,
              filter: function(event, player) {
                var cards = [];
                game.getGlobalHistory('cardMove', function(evt) {
                  for (var i of evt.cards) {
                    if (get.position(i, true) == 'd' && get.color(i) == 'black') cards.push(i);
                  }
                });
                return cards.length > 0;
              },
              content: function() {
                'step 0'
                var cards = [];
                game.getGlobalHistory('cardMove', function(evt) {
                  if (evt.name == 'cardsDiscard' && evt.parent.name == 'orderingDiscard') return;
                  for (var i of evt.cards) {
                    if (get.position(i, true) == 'd' && get.color(i) == 'black' && !cards.contains(i)) cards.push(i);
                  }
                });
                player.chooseCardButton(cards).set('filterButton', function(button) {
                  return (lib.filter.cardEnabled(button.link, player) && lib.filter.cardUsable(button.link, player) && game.hasPlayer(function(current) {
                    return player.canUse(button.link, current);
                  }));
                }).ai = function(button) {
                  return player.getUseValue(button.link);
                };
                'step 1'
                if (result.bool) {
                  player.chooseUseTarget(result.links[0], true);
                }

              },
            },

            shenxing3d8: {
              audio: "shenxing",
              trigger: {
                player: ["phaseDiscardEnd"],
              },
              frequent: true,
              filter: function(event, player) {
                return event.cards && event.cards.length > 0;
              },
              content: function() {
                player.draw(trigger.cards.length);
                player.chooseToUse();
              },
            },

            bingyi3d8: {
              audio: "shenxing",
              trigger: {
                player: ["phaseDrawAfter", "phaseJudgeAfter", "phaseUseAfter", "phaseDiscardAfter"],
              },
              frequent: true,
              filter: function(event, player) {
                return player.storage.bingyi3d8 == 1;
              },
              content: function() {
                "step 0"
                player.chooseTarget('选择一名角色，令其摸一张牌', function(card, player, target) {
                  return true;
                }).ai = function(target) {
                  if (get.attitude(player, target) <= 0) return -1;
                  if (target.countCards("h") >= 3) return 1;
                  return target.maxHp - target.hp + 4 - target.countCards("h");
                }
                "step 1"
                if (result.bool) {
                  result.targets[0].draw();
                }
              },
              group: ["bingyi3d8_start", "bingyi3d8_use"],
              subSkill: {
                start: {
                  trigger: {
                    player: ["phaseDrawBegin", "phaseJudgeBegin", "phaseUseBegin", "phaseDiscardBegin"],
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    player.storage.bingyi3d8 = 0;
                  },
                  sub: true,
                },
                use: {
                  trigger: {
                    player: "useCard",
                  },
                  forced: true,
                  popup: false,
                  content: function() {
                    player.storage.bingyi3d8 += 1;
                  },
                  sub: true,
                },
              },
            },

            sixing3d8: {
              audio: "huaiyi",
              trigger: {
                player: "phaseBegin",
              },
              forced: true,
              init: function(player) {
                player.storage.sixing3d8 = [];
              },
              filter: function(event, player) {
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i] == player) continue;
                  if (get.distance(player, players[i], 'attack') > 1) {
                    return true;
                  }
                }
                return false;
              },
              content: function() {
                player.draw();
                var ins = [];
                for (var i = 0; i < players.length; i++) {
                  if (players[i] == player) continue;
                  if (get.distance(player, players[i], 'attack') <= 1) ins.add(players[i]);
                }
                player.addTempSkill("sixing3d8_add");
              },
            },

            sixing3d8: {
              audio: "huaiyi",
              trigger: {
                player: "phaseBegin",
              },
              forced: true,
              init: function(player) {
                player.storage.sixing3d8 = [];
              },
              filter: function(event, player) {
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i] == player) continue;
                  if (get.distance(player, players[i], 'attack') > 1) {
                    return true;
                  }
                }
                return false;
              },
              content: function() {
                player.draw();
                player.storage.sixing3d8 = [];
                var ins = [];
                var players = game.filterPlayer();
                for (var i = 0; i < players.length; i++) {
                  if (players[i] == player) continue;
                  if (get.distance(player, players[i], 'attack') <= 1) ins.add(players[i]);
                }
                player.addTempSkill("sixing3d8_add");
                for (var i = 0; i < players.length; i++) {
                  if (players[i] == player) continue;
                  if (get.distance(player, players[i], 'attack') <= 1 && !ins.contains(players[i])) players[i].addTempSkill("sixing3d8_sha");
                }
              },
            },



            sixing3d8_add: {
              mod: {
                attackFrom: function(from, to, distance) {
                  return distance - 1;
                },
              },
              forced: true,
              popup: false,
            },

            sixing3d8_sha: {
              popup: false,
              trigger: {
                global: 'phaseJieshuBegin',
              },
              filter: function(event, player) {
                return event.player != player && event.player.hasSkill("sixing3d8_add") && lib.filter.targetEnabled2({
                  name: 'sha'
                }, player, event.player);
              },
              check: function(event, player) {
                return get.effect(event.player, {
                  name: 'sha'
                }, player, player) > 0;
              },
              content: function() {
                var next = player.chooseToUse();
                next.logSkill = 'sixing3d8_sha';
                next.set('openskilldialog', '肆行：将一张黑色手牌当【杀】对' + get.translation(trigger.player) + '使用');
                next.set('norestore', true);
                next.set('_backupevent', 'sixing3d8_shax');
                next.set('custom', {
                  add: {},
                  replace: {
                    window: function() {}
                  }
                });
                next.backup('sixing3d8_shax');
              },
            },

            sixing3d8_shax: {
              viewAs: {
                name: 'sha'
              },
              filterCard: {
                color: 'black'
              },
              position: 'h',
              check: function(card) {
                return 5.1 - get.value(card)
              },
              filterTarget: function(card, player, target) {
                return _status.currentPhase == target;
              },
            },

            zhunzhun3d8: {
              audio: "bingzheng",
              trigger: {
                global: "phaseDrawEnd",
              },
              filter: function(event, player) {
                return player.countCards('h') > 0 && event.player != player && event.player.countCards('h') > 0;
              },
              check: function(event, player) {
                var att = get.attitude(player, event.player);
                var cards = player.getCards("h");
                if (att < 0) {
                  for (var i = 0; i < cards.length; i++) {
                    if (get.value(cards[i]) < 5 && cards[i].number > Math.min(12, 6 + event.player.countCards('h'))) return true;
                  }
                  return false;
                } else if (att > 0) {
                  for (var i = 0; i < cards.length; i++) {
                    if (get.value(cards[i]) < 8 && cards[i].number < Math.min(12, 5 + event.player.countCards('h'))) return true;
                  }
                  return false;
                }
                for (var i = 0; i < cards.length; i++) {
                  if (cards[i].name == 'du') return true;
                }
                return false;
              },
              content: function() {
                'step 0'
                event.target = trigger.player;
                'step 1'
                player.chooseToCompare(event.target).set('small', get.attitude(player, event.target) > 0);
                'step 2'
                if (!result.bool) {
                  event.target.draw(2);
                  player.storage.zhunzhun3d8_card = result.target;
                  event.goto(3);
                } else event.finish();
                'step 3'
                event.list = ['继续', '不继续']
                player.chooseControl(event.list, true).set('prompt', '谆谆：是否继续拼点？').ai = function() {
                  //console.log(player.storage.zhunzhun3d8_card);
                  var att = get.attitude(player, event.target);
                  if (att < 0) {
                    if (player.storage.zhunzhun3d8_card.number > Math.min(12, 6 + event.target.countCards('h'))) return '继续';
                    return '不继续';
                  } else if (att > 0) {
                    if (player.storage.zhunzhun3d8_card.number < Math.min(12, 5 + event.target.countCards('h'))) return '继续';
                    return '不继续';
                  }
                  return '不继续';
                };
                'step 4'
                if (result.control == '继续') {
                  var next = player.chooseToCompare(event.target).set('small', get.attitude(player, event.target) > 0).set('fixedResult', true);
                  next.fixedResult = {};
                  next.fixedResult[player.playerid] = player.storage.zhunzhun3d8_card;
                } else event.finish();
                'step 5'
                if (!result.bool) {
                  event.target.draw(2);
                  player.storage.zhunzhun3d8_card = result.target;
                  event.goto(3);
                } else event.finish();
              },
              ai: {
                expose: 0.7,
                threaten: 1.2,
              },
            },

            danbo3d8: {
              audio: "sheyan",
              trigger: {
                target: "useCardToBefore",
              },
              filter: function(event, player) {
                if (player == _status.currentPhase) return false;
                return event.card && get.color(event.card) == 'red';
              },
              frequent: true,
              content: function() {
                event.cards = get.cards(3);
                player.showCards(event.cards);
                var num = 100;
                for (var i = 0; i < event.cards.length; i++) {
                  num = Math.min(num, event.cards[i].number);
                }
                var cards = [];
                for (var i = 0; i < event.cards.length; i++) {
                  if (event.cards[i].number == num) cards.push(event.cards[i]);
                }
                player.gain(cards, 'gain2');
              },
            },

            kongshe3d8: {
              audio: "jigong",
              enable: "phaseUse",
              usable: 1,
              filter: function(event, player) {
                return player.countCards('h') > 0 && game.hasPlayer(function(current) {
                  return current.countCards('h') > player.countCards('h');
                });
              },
              filterTarget: function(card, player, target) {
                return player != target && target.countCards('h') > player.countCards('h');
              },
              content: function() {
                "step 0"
                //player.logSkill('kongshe3d8',target); 
                var list = [];
                var count = player.countCards("h");
                for (var i = 0; i <= count; i++) {
                  list.push(i.toString())
                }
                event.list = list;
                player.chooseControl(list, true).set('prompt', '恐慑：选择弃置手牌的数量').ai = function() {
                  rubbish = 0;
                  du = 0;
                  good = 0;
                  var cards = player.getCards("h");
                  var count = player.countCards("h");
                  for (var i = 0; i < cards.length; i++) {
                    if (get.value(cards[i]) < 5) rubbish += 1;
                    if (cards[i].name == 'du') du += 1;
                    if (get.value(cards[i]) >= 8) good += 1;
                  }
                  if (good == count) {
                    if (Math.random() < 0.9) return "0";
                    return "1";
                  } else if (rubbish - du >= 1) {
                    if (rubbish - du == 1) return "1";
                    if (rubbish - du == 2) {
                      if (Math.random() > 0.5) return "2";
                      return "1";
                    }
                    if (rubbish - du > 2) {
                      if (Math.random() > 0.5) return (rubbish - du).toString();
                      if (Math.random() > 0.5) return "1";
                      return (Math.floor(Math.random() * (rubbish - du - 2)) + 2).toString();
                    }
                  }
                  var remain = count - good - rubbish - du;
                  if (remain == 0) return "0";
                  if (Math.random() < 0.2) return remain.toString();
                  return (Math.floor(Math.random() * remain)).toString();
                };
                "step 1"
                event.num1 = parseInt(result.control);
                target.chooseControl(event.list, true).set('prompt', '恐慑：选择弃置手牌的数量').ai = function() {
                  rubbish = 0;
                  du = 0;
                  good = 0;
                  var cards = player.getCards("h");
                  var count = player.countCards("h");
                  for (var i = 0; i < cards.length; i++) {
                    if (get.value(cards[i]) < 5) rubbish += 1;
                    if (cards[i].name == 'du') du += 1;
                    if (get.value(cards[i]) >= 8) good += 1;
                  }
                  var remain = count - good - du;
                  if (good == count) {
                    if (Math.random() < 0.5) return "0";
                    return "1";
                  } else if (remain >= 1) {
                    if (remain == 1) return "1";
                    if (remain == 2) {
                      if (Math.random() < 0.35) return "2";
                      return "1";
                    }
                    if (remain > 2) {
                      if (Math.random() < 0.2) return remain.toString();
                      if (Math.random() < 0.4) return "1";
                      return (Math.floor(Math.random() * (remain - 2)) + 2).toString();
                    }
                  }
                  return "1";
                };
                "step 2"
                event.num2 = parseInt(result.control);
                if (event.num1 > 0) {
                  player.chooseCard('选择弃置的牌', 'h', event.num1, true).set('ai', function(card) {
                    if (card.name == 'du') return 0.5;
                    else if (get.value(card) >= 8) return 0.6;
                    return 8 - get.value(card);
                  });
                }
                "step 3"
                if (result.cards) event.cards1 = result.cards;
                else event.cards1 = [];
                if (event.num2 > 0) {
                  target.chooseCard('选择弃置的牌', 'h', event.num2, true).set('ai', function(card) {
                    if (card.name == 'du') return 0.5;
                    else if (get.value(card) >= 8) return 0.6;
                    return 8 - get.value(card);
                  });
                }
                "step 4"
                if (result.cards) event.cards2 = result.cards;
                else event.cards2 = [];
                if (event.cards1) player.discard(event.cards1);
                if (event.cards2) target.discard(event.cards2);
                if (event.num1 > event.num2) target.damage();
              },
              ai: {
                order: 1,
                expose: 0.8,
                threaten: 3,
                result: {
                  player: function(player, target) {
                    return -1;
                  },
                  target: function(player, target) {
                    var count = target.countCards("h");
                    if (target.hp <= 2 && count <= 3) return -3;
                    return -2;
                  },
                },
              },
            },

            gouxian3d8: {
              audio: "shifei",
              enable: "phaseUse",
              usable: 1,
              filter: function(event, player) {
                return player.countCards('h') > 0 && game.hasPlayer(function(current) {
                  return current.countCards('h') < player.countCards('h');
                }) && player.countCards('he', {
                  suit: 'spade'
                }) > 0;
              },
              filterTarget: function(card, player, target) {
                return player != target && target.countCards('h') < player.countCards('h');
              },
              filterCard: function(card) {
                return get.suit(card) == 'spade';
              },
              check: function(card) {
                return 6 - get.value(card);
              },
              selectCard: 1,
              position: 'he',
              discard: false,
              lose: false,
              content: function() {
                'step 0'
                //player.logSkill('gouxian3d8',target); 
                target.gain(cards, player, 'giveAuto');
                event.list = [];
                'step 1'
                var count = target.countCards("h");
                for (var i = 1; i <= count; i++) {
                  event.list.push(i.toString())
                }
                player.chooseControl(event.list, true).set('prompt', '构陷：选择展示手牌的数量').ai = function() {
                  var count = target.countCards("h");
                  if (count <= 2) return "1";
                  if (count == 3) {
                    if (Math.random() > 0.3) return "2";
                    return "1";
                  }
                  //1~(n-1) normal distribution
                  if ((player.hp >= 3 && Math.random() > 0.4) || (player.hp < 3 && Math.random() > 0.8)) {
                    var rand = 0;

                    for (var i = 0; i < 6; i += 1) {
                      rand += Math.random();
                    }

                    var num = rand / 6;
                    return Math.floor(1 + num * (count - 1 - 1 + 1)).toString();
                  }
                  if (Math.random() > 0.35) return (count - 1).toString();
                  if (Math.random() > 0.35) return (count - 2).toString();
                  return (count - 3).toString();
                };
                'step 2'
                var cards = target.getCards("h");
                event.count = parseInt(result.control);
                event.cards1 = cards.randomGets(event.count);
                event.cards2 = cards.filter(x => !event.cards1.includes(x));
                player.showCards(event.cards1);
                game.delay(0.5)
                var flag = 0;
                for (var i = 0; i < event.cards1.length; i++) {
                  if (get.suit(event.cards1[i]) == 'spade') flag = 1;
                }
                if (flag == 1) {
                  player.gain(event.cards2, target, 'giveAuto');
                }
              },
              ai: {
                order: 7,
                expose: 0.8,
                threaten: 3,
                result: {
                  player: function(player, target) {
                    return 0;
                  },
                  target: function(player, target) {
                    if (!target.countCards("h") || target.countCards("h") == 0) return 0;
                    if (target.countCards("h") > 2) return -2;
                    return -1;
                  }
                },
              },
            },

            zhiheng3d8: {
              audio: "rezhiheng",
              enable: "phaseUse",
              usable: 1,
              content: function() {
                'step 0'
                player.chooseCard('he', '重铸一张牌')
                  .ai = function(card) {
                    var player = _status.event.player;
                    var equip_cards = player.getCards("e");
                    if (card.name == 'du' && player.hp == 1) return 0;
                    if (equip_cards.indexOf(card) >= 0 || (!game.hasPlayer(function(current) {
                        return player.canUse(card, current);
                      }) || !lib.filter.cardUsable(card, player) || player.getCardUsable(card) == 0)) return 8 - get.value(card);
                    return 6 - get.value(card);
                  };
                'step 1'
                if (result.bool) {
                  var equip_cards = player.getCards("e");
                  var card = result.cards[0];
                  var flag = 0;
                  if (equip_cards.indexOf(card) >= 0 || (!game.hasPlayer(function(current) {
                      return player.canUse(card, current);
                    }) || !lib.filter.cardUsable(card, player) || player.getCardUsable(card) == 0)) flag = 1;
                  player.discard(result.cards);
                  player.draw();
                  if (flag == 1) player.draw();
                }
              },
              ai: {
                order: 1,
                result: {
                  player: function(player, target) {
                    var player = _status.event.player;
                    var cards = player.getCards("h");
                    var equip_cards = player.getCards("e");
                    for (var i = 0; i < cards.length; i++) {
                      var card = cards[i];
                      if (card.name == 'du' && player.hp == 1) continue;
                      if (!game.hasPlayer(function(current) {
                          return player.canUse(card, current);
                        }) && 8 - get.value(card) > 0) return 1;
                      else if (6 - get.value(card) > 0) return 1;
                    }
                    for (var i = 0; i < equip_cards.length; i++) {
                      var card = cards[i];
                      if (8 - get.value(card) > 0) return 1;
                    }
                    return 0;
                  }
                },
                threaten: 1.55,
              },
            },

            zhuangcheng3d8: {
              audio: "yanxiao",
              trigger: {
                global: "phaseBegin",
              },
              filter: function(event, player) {
                return event.player != player && player.countCards('h') > 1 && (!event.player.hasJudge("lebu"));
              },
              check: function(event, player) {
                if (get.attitude(player, event.player) >= 0) return false;
                var count = event.player.countCards("h") - event.player.getHandcardLimit();
                if (count <= 0) {
                  if (player.countCards('h') > 2) return false;
                  var cards = player.getCards("h");
                  for (var i = 0; i < cards.length; i++) {
                    if (get.value(cards[i]) <= 6 && cards[i].name != 'du') return true;
                  }
                  return false;
                }
                var cards = player.getCards("h");
                var count1 = 0;
                for (var i = 0; i < cards.length; i++) {
                  if (get.value(cards[i]) <= 6 && cards[i].name != 'du') count1 += 1;
                }
                return count1 >= cards.length - 1 && count1 <= count;

              },
              content: function() {
                "step 0"
                player.chooseToDiscard(player.countCards("h") - 1, true);
                "step 1"
                if (result.bool) {
                  var card = game.createCard2('lebu', 'diamond', 1);
                  trigger.player.addJudge('lebu', card);
                }
              },
            },

            buluo3d8: {
              audio: "anxian",
              trigger: {
                player: ["chooseToRespondBefore", "chooseToUseBefore"],
              },
              filter: function(event, player) {
                if (event.responded) return false;
                if (!event.filterCard({
                    name: 'shan'
                  }, player, event)) return false;
                if (player.countCards("h") >= player.maxHp) return false;
                return player.countCards('h', {
                  name: 'shan'
                }) == 0;
              },
              frequent: true,
              content: function() {
                player.showHandcards();
                player.draw(player.maxHp - player.countCards("h"));
              },
              ai: {
                effect: {
                  target: function(card, player, target, current) {
                    if (card.name == 'sha' && target.countCards("h") == 0 && target.maxHp > 2) return [1, target.maxHp - 2];
                  },
                },
              },
            },

            sujiediy: {
              mark: true,
              locked: false,
              zhuanhuanji: true,
              marktext: "素",
              intro: {
                content: function(storage, player, skill) {
                  if (player.storage.sujie != true) return '你的出牌阶段结束时，若你于该阶段仅使用一种颜色的牌，你可弃置场上与其颜色不同的一张牌。';
                  return '其他角色的出牌阶段结束时，若其于该阶段使用了两种颜色的牌，你可获得本阶段进入弃牌堆的一张牌。';
                },
              },
              group: ["sujiediy_1", "sujiediy_2", "sujiediy_use", "sujiediy_init"],
              subSkill: {
                "1": {
                  sub: true,
                  prompt: '你的出牌阶段结束时，若你于该阶段仅使用一种颜色的牌，你可弃置场上与其颜色不同的一张牌。',
                  trigger: {
                    player: "phaseUseEnd",
                  },
                  filter: function(event, player) {
                    if (player.storage.sujie == true) return false;
                    var map = {};
                    var list = event.player.getHistory('useCard', function(evt) {
                      var evt2 = evt.getParent('phaseUse');
                      return evt2 == event;
                    });
                    if (list.length == 0) return false;
                    var black = 0;
                    var red = 0;
                    var not = 0;
                    for (var i = 0; i < list.length; i++) {
                      if (get.color(list[i].card) == 'black') black += 1;
                      else if (get.color(list[i].card) == 'red') red += 1;
                      else not += 1;
                    }
                    if (black > 0 && red == 0) return true;
                    if (black == 0 && red > 0) return true;
                    return false;
                  },
                  frequent: true,
                  content: function() {
                    "step 0"
                    var list = trigger.player.getHistory('useCard', function(evt) {
                      var evt2 = evt.getParent('phaseUse');
                      return evt2 == trigger;
                    });
                    var black = 0;
                    var red = 0;
                    var not = 0;
                    for (var i = 0; i < list.length; i++) {
                      if (get.color(list[i].card) == 'black') black += 1;
                      else if (get.color(list[i].card) == 'red') red += 1;
                      else not += 1;
                    }
                    if (black > 0 && red == 0) event.color = 'black';
                    if (black == 0 && red > 0) event.color = 'red';
                    "step 1"
                    if (event.color) {
                      player.chooseTarget('请选择一名角色，弃置其场上一张颜色不同的牌', function(card, player, target) {
                        if (!target.countCards('ej') || target.countCards('ej') == 0) return false;
                        var cards = target.getCards("ej");
                        for (var i = 0; i < cards.length; i++) {
                          if (get.color(cards[i]) != event.color) return true;
                        }
                        return false;
                      }).set('ai', function(target) {
                        var player = _status.event.player;
                        var att = get.attitude(player, target);

                        if (att > 0) {
                          var js = target.getCards('j');
                          if (js.length) {
                            var jj = js[0].viewAs ? {
                              name: js[0].viewAs
                            } : js[0];
                            var flag = 0;
                            for (var i = 0; i < js.length; i++) {
                              if (get.color(js[i]) != event.color) flag = 1;
                            }
                            if (flag == 1 && (jj.name == 'guohe' || js.length > 1 || get.effect(target, jj, target, player) < 0)) {
                              return 2 * att;
                            }
                          }
                          if (target.getEquip('baiyin') && target.isDamaged() &&
                            get.recoverEffect(target, player, player) > 0 && event.color != 'black') {
                            if (target.hp == 1 && !target.hujia) return 1.6 * att;
                            if (target.hp == 2) return 0.01 * att;
                            return 0;
                          }
                        }
                        var es = target.getCards('e');
                        var noe = target.hasSkillTag('noe');
                        var noe2 = (es.length == 1 && es[0].name == 'baiyin' && target.isDamaged() && event.color != 'black');
                        if (noe || noe2) return 0;
                        if (att <= 0 && !es.length) return 1.5 * att;
                        var flag = 0;
                        for (var i = 0; i < es.length; i++) {
                          if (get.color(es[i]) != event.color) flag = 1;
                        }
                        if (flag == 1) return -1.5 * att;
                        return 0;
                      });
                    } else event.finish();
                    'step 2'
                    if (result.bool) {
                      event.target = result.targets[0];
                      event.target.addExpose(0.1);
                      player.logSkill('hx_sujie', event.target);
                      game.delayx();
                    } else event.finish();
                    'step 3'
                    if (event.target) {
                      player.discardPlayerCard(event.target, "ej").set('filterButton', function(button) {
                        return get.color(button.link) != event.color;
                      }).set('ai', function(button) {
                        var tar = event.target;
                        var att = get.attitude(player, tar);
                        if (att > 0) {
                          if (get.type(button.link) == 'delay' && button.link.name != 'XS_mantian') return 10;
                          return -1;
                        } else {
                          if (get.type(button.link) == 'delay' && button.link.name != 'XS_mantian') return -1;
                          return 1 + get.value(button.link);
                        }
                      });
                    } else event.finish();
                    'step 4'
                    if (result.bool) {
                      player.storage.sujie = true;
                    } else event.finish();
                  },
                  ai: {
                    effect: {
                      player: function(card, player, target, current) {
                        if (!player.isPhaseUsing()) return;
                        if (player.storage.sujie == true) return false;
                        var cards = player.storage.sujie_cards;
                        var black = 0;
                        var red = 0;
                        var not = 0;
                        for (var i = 0; i < cards.length; i++) {
                          if (get.color(cards[i]) == 'black') black += 1;
                          else if (get.color(cards[i]) == 'red') red += 1;
                          else not += 1;
                        }
                        var color = get.color(card);
                        if (color != 'red' && color != 'black') return;
                        if (color == 'red' && red == 0 && black > 0) return [1, 0, 1, -1];
                        if (color == 'black' && red > 0 && black == 0) return [1, 0, 1, -1];
                        return;
                      },
                    },
                  },
                },
                "2": {
                  sub: true,
                  prompt: '其他角色的出牌阶段结束时，若其于该阶段使用了两种颜色的牌，你可获得本阶段进入弃牌堆的一张牌。',
                  trigger: {
                    global: "phaseUseEnd",
                  },
                  filter: function(event, player) {
                    if (player == _status.currentPhase) return false;
                    if (player.storage.sujie != true) return false;
                    var map = {};
                    var list = event.player.getHistory('useCard', function(evt) {
                      var evt2 = evt.getParent('phaseUse');
                      return evt2 == event;
                    });
                    if (list.length == 0) return false;
                    var black = 0;
                    var red = 0;
                    var not = 0;
                    for (var i = 0; i < list.length; i++) {
                      if (get.color(list[i].card) == 'black') black += 1;
                      else if (get.color(list[i].card) == 'red') red += 1;
                      else not += 1;
                    }
                    var cards = [];
                    game.getGlobalHistory('cardMove', function(evt) {
                      console.log(evt.getParent('phaseUse'));
                      if (evt.getParent('phaseUse') == event) {
                        cards.addArray(evt.cards.filterInD('d'));
                      }
                    });
                    if (cards.length == 0) return false;
                    if (black > 0 && red > 0) return true;
                    return false;
                  },
                  check: function(event, player) {
                    var cards = [];
                    game.getGlobalHistory('cardMove', function(evt) {
                      console.log(evt.getParent('phaseUse'));
                      if (evt.getParent('phaseUse') == event) {
                        cards.addArray(evt.cards.filterInD('d'));
                      }
                    });
                    for (var i = 0; i < cards.length; i++) {
                      if (get.value(cards[i]) > 5) return true;
                    }
                    return false;
                  },
                  content: function() {
                    "step 0"
                    var cards = [];
                    game.getGlobalHistory('cardMove', function(evt) {
                      console.log(evt.getParent('phaseUse'));
                      if (evt.getParent('phaseUse') == trigger) {
                        cards.addArray(evt.cards.filterInD('d'));
                      }
                    });
                    player.chooseCardButton('获得一张牌', cards, function(button) {
                      return true;
                    }, true).set('ai', function(button) {
                      var current = _status.currentPhase;
                      var enemy = 0;
                      current = current.next;
                      while (current != player) {
                        if (get.attitude(player, current) < 0) enemy += 1;
                        current = current.next;
                      }
                      if (enemy >= player.hp) return get.useful(button.link);
                      return get.value(button.link);
                    }).set('filterButton', function(button) {
                      return true;
                    });
                    'step 1'
                    if (result.bool) {
                      player.gain(result.links[0], "gain");
                      player.storage.sujie = false;
                    } else event.finish();
                  },
                },
                "use": {
                  sub: true,
                  trigger: {
                    player: "useCard",
                  },
                  forced: true,
                  popup: false,
                  silent: true,
                  filter: function(event, player) {
                    return player.isPhaseUsing();
                  },
                  content: function() {
                    player.storage.sujie_cards.add(trigger.cards);
                  },
                },
                "init": {
                  sub: true,
                  trigger: {
                    player: "phaseUseBegin",
                  },
                  forced: true,
                  popup: false,
                  silent: true,
                  content: function() {
                    player.storage.sujie_cards = [];
                  },
                },
              },
            },

            moyidiy: {
              limited: true,
              skillAnimation: true,
              animationColor: "gray",
              trigger: {
                global: "loseAfter",
              },
              filter: function(event, player) {
                var p = event.player;
                if (p == player) return false;
                if (!p.isDamaged()) return false;
                if (!p.isAlive()) return false;
                return (!p.countCards('e') && event.es && event.es.length > 0) ||
                  (!p.countCards('h') && event.hs && event.hs.length > 0) ||
                  (!p.countCards('j') && event.js && event.js.length > 0);
              },
              check: function(event, player) {
                return get.attitude(player, event.player) > 0;
              },
              content: function() {
                'step 0'
                var list = ["是", "否"];
                player.chooseControl(list, true)
                  .set('prompt', '是否转换“素节”的状态？')
                  .ai = function() {
                    var current = _status.currentPhase;
                    var enemy = 0;
                    var user = 0;
                    current = current.next;
                    while (current != player) {
                      if (get.attitude(player, current) < 0) enemy += 1;
                      user += 1;
                      current = current.next;
                    }
                    if (player.storage.sujie != true) {
                      if (user >= 1) return '是';
                      return '否';
                    }
                    if (user >= 1) return '否';
                    return '是';
                  };
                'step 1'
                if (result.control) {
                  if (result.control == '是') {
                    game.log(player, "转换了“素节”的状态");
                    if (player.storage.sujie != true) player.storage.sujie = true;
                    else player.storage.sujie = false;
                  } else {
                    game.log(player, "未转换“素节”的状态");
                    if (player.storage.sujie == true) player.storage.sujie = false;
                    else player.storage.sujie = true;
                  }
                  player.awakenSkill('moyidiy');
                  player.addSkill("moyidiy_store");
                  trigger.player.recover();
                  player.storage.moyidiy_player = trigger.player;
                }
              },
              ai: {
                expose: 0.5,
                threaten: 3.5,
              },
            },

            moyidiy_store: {
              trigger: {
                global: "dyingBegin",
              },
              filter: function(event, player) {
                return player == event.player || player.storage.moyidiy_player == event.player;
              },
              silent: true,
              content: function() {
                player.restoreSkill("moyidiy");
                player.removeSkill("moyidiy_store");
              },
              forced: true,
              popup: false,
            },
          },
          translate: {
            person3d8: "个人精品",
            yaoshi: "耀世",
            liushuixi: "流水席",
            feizhi: "沸治",
            haohaizi: "好孩子系我",
            lapulasi: "拉普拉斯",
            diy: "DIY",

            "3d8_sp_zhugeliang": "诸葛亮",
            "3d8_luxun": "陆逊",
            "3d8_zhouyu": "周瑜",

            "3d8_jushou": "沮授",
            "3d8_dongbai": "董白",
            "3d8_zhongyao": "钟繇",
            "3d8_guyong": "顾雍",
            "3d8_gongsunyuan": "公孙渊",

            "3d8_dongyun": "董允",
            "3d8_guotufengji": "郭图逢纪",

            "3d8_sunquan": "孙权",

            "3d8_daqiao": "大乔",

            "diy_quezheng": "卻正",

            nangce3d8: "囊策",
            "nangce3d8_info": "你使用普通锦囊牌时，可令当前回合角色摸一张牌。",
            ruliao3d8: "入料",
            "ruliao3d8_info": "你可以将一张黑色牌当【闪】或【无懈可击】使用或打出。",
            duoshi3d8: "度势",
            "duoshi3d8_info": "阶段技，你可以弃置至多三张牌，然后令一名角色摸等量的牌。",
            guanying3d8: "观营",
            "guanying3d8_info": "当你失去一个区域的最后一张牌时，你可以摸一张牌。",
            qugu3d8: "曲顾",
            "qugu3d8_info": "准备阶段，你可令一名角色摸一张牌。",
            liejiang3d8: "烈江",
            "liejiang3d8_info": "阶段技，你可与一名其他角色交换一张手牌并展示，若花色不同，你对其造成1点火焰伤害。",

            zhongyan3d8: "忠言",
            "zhongyan3d8_info": "出牌阶段开始时，你可以令一名其他角色摸X张牌（X为你的体力上限），然后该角色展示全部手牌；若其中不含有全部花色，你失去1点体力。",
            shibei3d8: "矢北",
            "shibei3d8_info": "锁定技，你受到的伤害均视为失去1点体力；当你处于濒死状态时，可以失去1点体力上限，然后恢复体力值至上限。",
            yishi3d8: "倚势",
            "yishi3d8_info": "锁定技，结束阶段开始时，你将体力值调整至与体力最多的其他角色相等；若该值高于你的体力上限，你摸一张牌。",
            zhulian3d8: "株连",
            "zhulian3d8_info": "锁定技，你的武将牌始终横置；每当你受到伤害时，你横置攻击范围内所有角色的武将牌。",
            kaizheng3d8: "楷正",
            "kaizheng3d8_info": "锁定技，你的主要阶段开始时，须将手牌数调整至体力上限值。",
            huihao3d8: "挥毫",
            "huihao3d8_info": "结束阶段开始时，你可以使用一张本回合进入弃牌堆的黑色牌。",
            shenxing3d8: "慎行",
            "shenxing3d8_info": "弃牌阶段结束时，你可以摸X张牌（X为你于此阶段弃置的手牌数），然后你可以使用一张牌。",
            bingyi3d8: "秉壹",
            "bingyi3d8_info": "你的主要阶段结束后，若你于此阶段仅使用过一张牌，你可以令一名角色摸一张牌。",
            sixing3d8: "肆行",
            "sixing3d8_info": "锁定技，回合开始时，若你的攻击范围外有角色，你摸两张牌并令本回合攻击范围+1。回合结束时，本回合以此法进入你攻击范围的角色可将一张黑色手牌当【杀】对你使用。",
            sixing3d8_sha: "肆行",
            "sixing3d8_sha_info": "",

            zhunzhun3d8: "谆谆",
            "zhunzhun3d8_info": "其他角色的摸牌阶段结束时，你可以与该角色拼点：若你没赢，其摸两张牌，然后你可以重复以上流程。",
            danbo3d8: "淡泊",
            "danbo3d8_info": "回合外，当你成为一张红色牌的目标时，你可以展示牌堆顶三张牌，然后获得当中点数最小的牌。",
            kongshe3d8: "恐慑",
            "kongshe3d8_info": "出牌阶段限一次，你可以指定一名手牌数大于你的角色，然后你与其同时弃置任意张手牌。若你弃置的牌多于该角色，你对其造成1点伤害。",
            gouxian3d8: "构陷",
            "gouxian3d8_info": "出牌阶段限一次，你可以将一张黑桃牌交给一名手牌数少于你的角色，然后展示其任意张手牌。若当中有黑桃牌，你获得该角色除展示牌外的所有手牌。",

            zhiheng3d8: "制衡",
            "zhiheng3d8_info": "出牌阶段限一次，你可以重铸一张牌，若此牌在此阶段已不能使用，你可以摸一张牌。",

            zhuangcheng3d8: "妆成",
            "zhuangcheng3d8_info": "其他角色的回合开始时，你可弃置手牌至一张，令其判定区置入【乐不思蜀】。",
            buluo3d8: "步落",
            "buluo3d8_info": "你需要使用或打出【闪】时，可展示手牌。若其中没有【闪】，将手牌补至体力上限。",

            sujiediy: "素节",
            "sujiediy_info": "转换技，①你②其他角色的出牌阶段结束时，若当前角色于该阶段使用了①一②两种颜色的牌，你可①弃置场上与其颜色不同②获得本阶段进入弃牌堆的一张牌。",
            moyidiy: "末义",
            "moyidiy_info": "限定技，一名已受伤的其他角色失去一个区域的最后一张牌时，你可选择是否转换“素节”，然后令其恢复1点体力。该角色或你进入濒死状态时，重置此技能。",

          },
        };
        if (lib.device || lib.node) {
          for (var i in person3d8.character) {
            person3d8.character[i][4].push('ext:贴吧精品/image/' + i + '.jpg');
          }
        } else {
          for (var i in race3d8.character) {
            person3d8.character[i][4].push('db:extension-贴吧精品/image:' + i + '.jpg');
          }
        }
        return person3d8;
      });


      // jlsg library
      lib.arenaReady.push(function() {
        lib.element.player.hasSkills = function(skills) {
          var skill = skills.split("|");
          for (var i = 0; i < skill.length; i++) {
            if (this.hasSkill(skill[i])) return true;
          }
          return false;
        }
      });
      var jlsg = {
        debug: {
          logCurrentRanks() {
            var logC = function(name) {
              console.log(`${name} ${get.translation(name)} ${get.rank(name)}`);
            };
            Array.from(document.getElementsByClassName('character')).filter(
              c => c.link
            ).forEach(
              c => logC(c.link)
            );
            if (!game.players || !game.players.forEach) return;
            game.players.forEach(
              p => {
                if (p.name1) logC(p.name1);
                if (p.name2) logC(p.name2);
              }
            )
          },
        },
        relu(num) {
          return num >= 0 ? num : 0;
        },
        showRepo() {
          var mirrorURL = lib.extensionPack["极略"] && lib.extensionPack["极略"].mirrorURL;
          if (!mirrorURL) return;
          if (window.cordova) {
            if (cordova.InAppBrowser) {
              return cordova.InAppBrowser.open(mirrorURL, '_system');
            }
            return;
          }
          if (window.require) {
            return require('electron').shell.openExternal(mirrorURL);
          }
          return window.open(mirrorURL);
        },
        showRepoElement(refElement) {
          let potentialRepo = refElement.nextElementSibling;
          if (potentialRepo && potentialRepo.id == "repo-link") {
            potentialRepo.remove();
          } else {
            refElement.insertAdjacentHTML('afterend', `<a id="repo-link" onclick="lib.jlsg.showRepo()" style="cursor: pointer;text-decoration: underline;display:block">Visit Repository</a>`);
            // refElement.nextElementSibling.scrollIntoView({
            //   behavior: 'smooth',
            //   block: 'nearest',
            // });
          }
        },
        getLoseHpEffect(player) {
          var loseHpEffect = -3;
          if (player.hp == 1) loseHpEffect *= 2.5;
          if (player.hp == 2) loseHpEffect *= 1.8;
          if (player.hp == 4) loseHpEffect *= 0.9;
          if (player.hp == 5) loseHpEffect *= 0.8;
          if (player.hp > 5) loseHpEffect *= 0.6;
          if (player.hasSkillTag('maihp')) loseHpEffect += 3;
          return loseHpEffect;
        },
        ai: {
          skill: {
            lose_equip: 'xiaoji|xuanfeng',
            need_kongcheng: 'shangshix|shangshi|jlsg_ruya|jlsg_qicai|lianying|relianying|kongcheng|sijian|hengzheng',
            rejudge: 'guicai|jlsg_guicai|guidao|jilve|nos_zhenlie|huanshi|midao',
            save: 'jlsg_guagu|jlsg_fangxin|jlsg_renxin|jijiu|buyi|chunlao|longhun|jlsg_longhun',
            need_card: 'jlsg_youdi|jlsg_rende|jlsg_liuyun|jlsg_yansha|jlsg_huiqu|jlsg_zhaoxiang|kanpo|guicai|jlsg_guicai|guidao|beige|xiaoguo|liuli|tianxiang|jijiu|leiji|releiji|qingjian|zhuhai|qinxue|danqi',
            recover: 'jlsg_liuyun|jlsg_zhishi|rerende|rende|kuanggu|zaiqi|jieyin|qingnang|yinghun|hunzi|shenzhi|longhun|zishou|ganlu|xueji|shangshi|chengxiang|buqu|quji',
            use_lion: 'longhun|duanliang|qixi|guidao|relijian|lijian|xinjujian|jujian|zhiheng|mingce|yongsi|fenxun|gongqi|yinling|jilve|qingcheng',
            need_equip: 'shensu|mingce|jujian|jlsg_liuyun|beige|yuanhu|huyuan|gongqi|gongji|yanzheng|qingcheng|longhun|shuijian|yinbing',
            straight_damage: 'jlsg_chouxi|jlsg_zhishi|qiangxi|duwu|danshou',
            double_sha: 'paoxiao|fuhun|tianyi|xianzhen|zhaxiang|lihuo|jiangchi|shuangxiong|qiangwu|luanji',
            need_maxhp: 'jlsg_ruya|yingzi|zaiqi|yinghun|hunzi|juejing|ganlu|zishou|miji|chizhong|xueji|quji|xuehen|jushou|tannang|fangzhu|shangshi|miji',
            bad_skills: 'benghuai|jlsg_wumou|shiyong|jlsg_shiyong|yaowu|chanyuan|chouhai',
            break_sha: 'jlsg_zhaoxiang|jlsg_yansha',
            maixie_skill: 'guixin|yiji|fankui|jieming|xuehen|neoganglie|ganglie|vsganglie|enyuan|fangzhu|nosenyuan|langgu|quanji|zhiyu|renjie|tanlan|tongxin|huashen|duodao|chengxiang|benyu',
          }
        },
        sort: {
          hp: function(a, b) {
            var c1 = a.hp;
            var c2 = b.hp;
            if (c1 == c2) {
              return jlsg.sort.threat(a, b);
            }
            return c1 > c2;
          },
          handcard: function(a, b) {
            var c1 = a.num('h');
            var c2 = b.num('h');
            if (c1 == c2) {
              return jlsg.sort.defense(a, b);
            }
            return c1 < c2;
          },
          value: function(a, b) {
            return jlsg.getValue(a) < jlsg.getValue(b);
          },
          chaofeng: function(a, b) {
            return jlsg.getDefense(a) > jlsg.getDefense(b);
          },
          defense: function(a, b) {
            return jlsg.getDefenseSha(a) < jlsg.getDefenseSha(b);
          },
          threat: function(a, b) {
            var d1 = a.num('h');
            for (var i = 0; i < game.players.length; i++) {
              if (a.canUse('sha', game.players[i]) && a != game.players[i]) {
                d1 = d1 + 10 / (jlsg.getDefense(game.players[i]))
              }
            }
            var d2 = b.num('h');
            for (var i = 0; i < game.players.length; i++) {
              if (b.canUse('sha', game.players[i]) && b != game.players[i]) {
                d2 = d2 + 10 / (jlsg.getDefense(game.players[i]))
              }
            }
            return d1 > d2;
          }
        },
        isKongcheng: function(player) {
          return player.countCards('h') == 0;
        },
        needKongcheng: function(player, keep) {
          if (keep) {
            return jlsg.isKongcheng(player) && (player.hasSkill('kongcheng') || (player.hasSkill('zhiji') && !player.storage.zhiji));
          }
          if (!jlsg.hasLoseHandcardEffective(player) && !jlsg.isKongcheng(player)) return true;
          if (player.hasSkill('zhiji') && !player.storage.zhiji) return true;
          return player.hasSkills(jlsg.ai.skill.need_kongcheng);
        },
        hasBaguaEffect: function(player) {
          if (player.countCards('e', 'bagua')) return true;
          if (player.hasSkill('bazhen') && !player.get('e', '2')) return true;
          if (player.hasSkill('linglong') && !player.get('e', '2')) return true;
          return false;
        },
        hasBuquEffect: function(player) {
          if (player.hasSkill('buqu')) {
            if (player.storage.buqu == undefined) return true;
            if (player.storage.buqu && player.storage.buqu.length <= 4) return true;
            return false;
          }
          return false;
        },
        hasZhuqueEffect: function(player) {
          var cards = player.get('h');
          for (var i = 0; i < cards.length; i++) {
            if (cards[i].name == 'sha' && cards[i].nature == 'fire') return true;
            if (player.countCards('e', 'zhuque') && cards[i].name == 'sha' && !cards[i].nature) return true;
          }
          return false;
        },
        hasJiuEffect: function(player) {
          if (player.hasSkills('jiu|boss_zuijiu|luoyi2|reluoyi2|jie|nuzhan2|anjian|jlsg_huxiao|jlsg_jiwu_buff1|jlsg_wenjiu3')) return true;
          if (player.hasSkills('jlsg_ganglie_damage|jlsg_fenwei')) return true;
          if (player.hasSkill('jieyuan') && player.countCards('h') >= 2)
            if (player.hasSkill('chouhai') && jlsg.isKongcheng(player)) return true;
          if (player.hasSkill('qingxi')) {
            var num = 1;
            var info = get.info(player.get('e', '1'));
            if (info && info.distance && info.distance.attackFrom) {
              num -= info.distance.attackFrom;
            }
            return num > 1;
          }
          return false;
        },
        hasWushuangEffect: function(player) {
          if (player.hasSkills('wushuang|jlsg_shejing')) return true;
          return false;
        },
        hasZhugeEffect: function(player) {
          if (player.countCards('e', 'zhuge')) return true;
          if (player.hasSkills('paoxiao|tianyi2|zhanlong2|xianzhen2|jlsg_shayi')) return true;
          return false;
        },
        loseCardEffect: function(player) {
          if (jlsg.needKongcheng(player)) return 3;
          if (jlsg.getLeastHandcardNum(player) > 0) return 1;
          return -player.countCards('h');
        },
        gainCardEffect: function(player) {
          if (jlsg.needKongcheng(target, true)) return -1;
          if (jlsg.getOverflow(player)) return 0;
          return 3;
        },
        getLeastHandcardNum: function(player) {
          var least = 0;
          if (player.hasSkills('lianying|relianying') && least < 1) least = 1;
          if (player.hasSkill('jlsg_ruya') && least < player.maxHp) least = player.maxHp;
          if (player.hasSkill('shangshix') && least < 4) least = 4;
          var jwfy = jlsg.findPlayerBySkillName('shoucheng');
          if (least < 1 && jwfy && jlsg.isFriend(player, jwfy)) least = 1;
          if (player.hasSkill('shangshi') && least < Math.min(2, jlsg.getLostHp(player))) least = Math.min(2, jlsg.getLostHp(player));
          return least;
        },
        hasLoseHandcardEffective: function(player) {
          return player.countCards('h') > jlsg.getLeastHandcardNum(player);
        },
        isWeak: function(player) {
          if (jlsg.hasBuquEffect(player)) return false;
          if (player.hasSkill('longhun') && player.countCards('he') > 2) return false;
          if (player.hasSkill('jlsg_longhun') && player.countCards('he') > 2) return false;
          if (player.hasSkill('hunzi') && !player.storage.hunzi && player.hp > 1) return false;
          if ((player.hp <= 2 && player.countCards('h') <= 2) || player.hp <= 1) return true;
          return false;
        },
        getLostHp: function(player) {
          return player.maxHp - player.hp;
        },
        getBestHp: function(player) {
          var arr = {
            ganlu: 1,
            yinghun: 2,
            xueji: 1,
            baobian: Math.max(0, player.maxHp - 3),
          };
          if (player.hasSkill('longhun') && player.countCards('he') > 2) return 1;
          if (player.hasSkill('hunzi') && !player.storage.hunzi) return 2;
          for (var i in arr) {
            if (player.hasSkill(i)) {
              return Math.max((player.isZhu && 3 || 2), player.maxHp - arr[i])
            }
          }
          if (player.hasSkill('renjie') && player.hasSkill('sbaiyin')) return player.maxHp - 1;
          if (player.hasSkill('quanji') && player.hasSkill('zili')) return player.maxHp - 1;
          return player.maxHp;
        },
        getValue: function(player) {
          return player.hp * 2 + player.countCards('h');
        },
        isGoodHp: function(player) {
          if (player.hp > 1 || jlsg.getCardsNum('tao', player) >= 1 || jlsg.getCardsNum('jiu', player) >= 1) return true;
          if (jlsg.hasBuquEffect(player)) return true;
          if (player.hasSkill('niepan') && !player.storage.niepan) return true;
          if (player.hasSkill('reniepan') && !player.storage.reniepan) return true;
          if (player.hasSkill('jlsg_zhuizun') && !player.storage.jlsg_zhuizun) return true;
          if (player.hasSkill('fuli') && !player.storage.fuli) return true;
          return false;
        },
        isScure: function(player) {
          if (player.hp > jlsg.getBestHp(player)) return true;
          if (jlsg.countCanShaMe(player) <= 0) return true;
          if (jlsg.isGoodHp(player)) return true;
          return false;
        },
        needBear: function(player) {
          return (player.hasSkill('renjie') && player.hasSkill('sbaiyin') && !player.hasSkill('jilue') && player.storage.renjie < 4) || (player.hasSkill('qinxue') && !player.storage.qinxue);
        },
        cardNeed: function(card, player) {
          if (player == undefined || get.itemtype(player) != 'player') player = get.owner(card);
          var friends = jlsg.getFriends(player).sort(jlsg.sort.hp);
          if (!friends.length) return null;
          if (card.name == 'tao') {
            friends.sort(jlsg.sort.hp);
            if (friends[0].hp < 2) return 10;
            if (player.hp < 3 || (jlsg.getLostHp(player) > 1 && !player.hasSkills('longhun|buqu|jlsg_longhun')) || player.hasSkills('kurou|benghuai')) return 14;
            return jlsg.getUseValue(card, player);
          }
          var wuguotai = jlsg.findPlayerBySkillName('buyi');
          if (wuguotai && jlsg.isFriend(player, wuguotai) && get.type(card) != 'basic') {
            if (player.hp < 3 || (jlsg.getLostHp(player) > 1 && !player.hasSkills('longhun|buqu|jlsg_longhun')) || player.hasSkills('kurou|benghuai')) return 13;
          }
          if (jlsg.isWeak(player) && card.name == 'shan' && jlsg.getCardsNum('shan', player, player) < 1) return 12;
          return 0;
        },
        getOverflow: function(player, getMaxCards) {
          var kingdom_num = 0;
          if (player.hasSkill('yongsi') && _status.currentPhase == player && !(player.hasSkill('keji') && get.cardCount({
              name: 'sha'
            }, player) == 0)) {
            var list = ['wei', 'shu', 'wu', 'qun'];
            for (var i = 0; i < game.players.length && list.length; i++) {
              if (list.contains(game.players[i].group)) {
                list.remove(game.players[i].group);
                kingdom_num++;
              }
            }
          }
          var MaxCards = 0;
          if (player.hasSkill('qiaobian')) MaxCards = Math.max(player.countCards('h') - 1, player.getHandcardLimit());
          if (player.hasSkill('keji') && get.cardCount({
              name: 'sha'
            }, player) == 0) MaxCards = player.countCards('h');
          if (getMaxCards && MaxCards > 0) return MaxCards;
          MaxCards = player.getHandcardLimit();
          if (kingdom_num > 0) {
            if (player.countCards('he') <= kingdom_num) MaxCards = 0;
            else MaxCards = Math.min(player.getHandcardLimit(), player.countCards('he') - kingdom_num);
            if (getMaxCards) return MaxCards;
          }
          if (getMaxCards) return player.getHandcardLimit();
          return player.countCards('h') - MaxCards;
        },
        willSkipPhaseUse: function(player) {
          var friend_wuxie = 0;
          for (var i = 0; i < game.players.length; i++) {
            if (jlsg.isFriend(player, game.players[i])) friend_wuxie = friend_wuxie + jlsg.getCardsNum('wuxie', game.players[i], player);
            if (jlsg.isEnemy(player, game.players[i])) friend_wuxie = friend_wuxie - jlsg.getCardsNum('wuxie', game.players[i], player);
          }
          if (player.skipList.contains('phaseUse')) return true;
          if (player.hasJudge('lebu') && !player.hasSkill('yanxiao2') && friend_wuxie <= 0) {
            if (!player.hasSkills('zongshi|keji|guanxing|qiaobian') && player.countCards('h') >= player.hp + 1) return true;
            return false;
          }
          return false;
        },
        willSkipPhaseDraw: function(player) {
          var friend_wuxie = 0;
          for (var i = 0; i < game.players.length; i++) {
            if (jlsg.isFriend(player, game.players[i])) friend_wuxie = friend_wuxie + jlsg.getCardsNum('wuxie', game.players[i], player);
            if (jlsg.isEnemy(player, game.players[i])) friend_wuxie = friend_wuxie - jlsg.getCardsNum('wuxie', game.players[i], player);
          }
          if (player.hasJudge('bingliang') && !player.hasSkill('yanxiao2') && friend_wuxie <= 0) {
            if (!player.hasSkills('guanxing|qiaobian') && player.countCards('h') <= player.hp + 2) return true;
            return false;
          }
          if (player.skipList.contains('phaseDraw')) return true;
          return false;
        },
        getViewAsCard: function(card, player) {
          var skills = player.get('s', true).concat(lib.skill.global);
          game.expandSkills(skills);
          var list = [];
          for (var i = 0; i < skills.length; i++) {
            var ifo = get.info(skills[i]);
            if (ifo.viewAs && ifo.viewAs.name && ifo.filterCard) {
              var filtercard = get.filter(ifo.filterCard);
              var pos = jlsg.getCardPlace(card);
              if ((ifo.selectCard == 1 || ifo.selectCard == undefined) && filtercard(card, player) && ((ifo.position && ifo.position.indexOf(pos) == 0) || !ifo.position && pos == 'h')) {
                return game.createCard({
                  name: ifo.viewAs.name,
                  suit: card.suit,
                  number: card.number
                });
              }
            }
          }
          return null;
        },
        getSkillViewCard: function(card, name, player, place) {
          var skills = player.get('s', true).concat(lib.skill.global);
          game.expandSkills(skills);
          for (var i = 0; i < skills.length; i++) {
            var ifo = get.info(skills[i]);
            if (ifo.viewAs && ifo.viewAs.name == name) {
              if (ifo.filterCard) {
                var filtercard = get.filter(ifo.filterCard);
                if (filtercard(card, player) && (ifo.selectCard == 1 || ifo.selectCard == undefined)) {
                  if (ifo.position && ifo.position.indexOf(place) == 0) return true;
                  if (!ifo.position) return place == 'h';
                }
              }
            }
          }
          return false;
        },
        getCardPlace: function(card) {
          var owner = get.owner(card);
          if (owner) {
            if (owner.get('h').contains(card)) return 'h';
            if (owner.get('e').contains(card)) return 'e';
            if (owner.get('j').contains(card)) return 'j';
            return 's';
          }
          return 's';
        },
        isCard: function(name, card, player) {
          if (!player || !card) return false;
          if (card.name != name) {
            var owner = get.owner(card);
            var place;
            if (!owner || player != owner) {
              place = 'h';
            } else {
              place = jlsg.getCardPlace(card);
            }
            if (jlsg.getSkillViewCard(card, name, player, place)) return true;
            if (player.hasSkill('wushen') && get.suit(card) == 'heart' && card.name != 'sha') return false;
            if (player.hasSkill('jinjiu') && card.name == 'jiu') return true;
          } else {
            if (player.hasSkill('wushen') && get.suit(card) == 'heart' && card.name == 'sha') return true;
            if (player.hasSkill('jinjiu') && card.name == 'jiu') return true;
            if (lib.filter.cardUsable(card, player)) return true;
          }
          return false;
        },
        getKnownCard: function(player, from, card_name, viewAs, flags) {
          flags = flags || 'h';
          var forbid = false;
          if (!from && player == _status.event.player) forbid = true;
          from = from || _status.event.player;
          var cards = player.get(flags);
          var know = 0;
          for (var i = 0; i < cards.length; i++) {
            var card = cards[i];
            if ((!forbid && player == from)) {
              if ((viewAs && jlsg.isCard(card_name, card, player)) || card.name == card_name || get.suit(card) == card_name || get.color(card) == card_name) {
                know++;
              }
            }
          }
          return know;
        },
        getDefenseSha: function(player, attacker) {
          if (attacker == undefined || get.itemtype(attacker) != 'player') attacker = _status.event.player;
          var defense = jlsg.getCardsNum('shan', player, attacker);
          var knownShan = jlsg.getKnownCard(player, attacker, 'shan', true);

          defense = defense + knownShan * 1.2;

          if (attacker.hasSkill('liegong')) {
            var length = player.countCards('h');
            if (length >= attacker.hp || length <= get.attackRange(attacker)) return 0;
          }
          if (attacker.hasSkill('reliegong')) {
            var num = 0;
            if (player.countCards('h') >= attacker.num('h')) num++;
            if (player.hp >= attacker.hp) num++;
            if (get.attackRange(player) <= get.attackRange(attacker)) num++;
            if (num > 0) return 0;
          }

          if (jlsg.hasBaguaEffect(player)) {
            defense += 1.3;
            if (player.hasSkill('tiandu')) defense += 0.6;
            if (player.hasSkill('leiji')) defense += 0.4;
            if (player.hasSkill('boss_leiji')) defense += 0.5;
            if (player.hasSkill('releiji')) defense += 0.4;
            if (player.hasSkill('hongyan')) defense += 0.2;
          }

          if (jlsg.getCardsNum('shan', player, _status.event.player) > 1) {
            if (player.hasSkill('mingzhe')) defense += 0.2;
            if (player.hasSkill('tuntian') && player.hasSkill('zaoxian')) defense += 1.5;
          }

          if (player.hasSkill('aocai') && _status.currentPhase !== player) defense += 0.5;
          if (player.hasSkill('jlsg_zhenlie')) defense += 0.5;
          if (player.hasSkill('jlsg_danshou') && !jlsg.isKongcheng(player) && !jlsg.isKongcheng(attacker)) defense += 0.5;

          var jlsgsk_zhuran = jlsg.findPlayerBySkillName('jlsg_yonglie');
          if (jlsgsk_zhuran && jlsg.isGoodHp(jlsgsk_zhuran)) {
            if (player.inRangeOf(jlsgsk_zhuran) && jlsg.isFriend(player, jlsgsk_zhuran)) defense += 0.5;
          }
          var jlsgsr_zhangliao = jlsg.findPlayerBySkillName('jlsg_yansha');
          if (jlsgsr_zhangliao && jlsgsr_zhangliao.storage.jlsg_yansha2 && jlsgsr_zhangliao.storage.jlsg_yansha2.length) {
            if (jlsg.isFriend(player, jlsgsr_zhangliao) && get.attitude(jlsgsr_zhangliao, attacker) < 0 && attacker.num('he')) defense += 0.5;
          }

          if (player.hasZhuSkill('hujia')) {
            var caocao = player;
            var list = game.filterPlayer(function(target) {
              return jlsg.isFriend(target, caocao) && target.group == 'wei' && target != caocao;
            });
            if (list.length > 0) {
              var hujiaShan = 0;
              for (var i = 0; i < list.length; i++) {
                hujiaShan += jlsg.getCardsNum('shan', list[i], _status.event.player);
                if (jlsg.hasBaguaEffect(list[i])) hujiaShan += 0.8;
              }
              defense += hujiaShan;
            }
          }
          defense = defense + Math.min(player.hp * 0.45, 10);
          if (attacker && !attacker.hasSkill('jueqing')) {
            if (player.hasSkillTag('maixie') && jlsg.isGoodHp(player)) defense++;

            if (player.hasSkill('jieming')) defense += 4;
            if (player.hasSkills('yiji|jlsg_yiji')) defense += 4;
            if (player.hasSkill('guixin')) defense += 4;
            if (player.hasSkill('yuce')) defense += 2;
          }

          if (player.hasSkills('rende|rerende') && player.hp > 2) defense++;
          if (player.hasSkill('kuanggu') && player.hp > 1) defense += 0.2;
          if (player.hasSkill('tianming') && player.hp > 1) defense += 0.1;
          if (player.hasSkills('zaiqi|rezaiqi') && player.hp > 1) defense += 0.35;
          if (player.hp > jlsg.getBestHp(player)) defense += 0.8;
          if (player.hp <= 2) defense -= 0.4;
          if (player.hasSkill('tianxiang')) defense += player.countCards('h') * 0.5;

          if (player.countCards('e', 'tengjia') && jlsg.hasZhuqueEffect(attacker) && !attacker.hasSkill('unequip')) defense -= 0.6;
          if (player.isZhu) {
            defense -= 0.4;
            if (jlsg.isZhuInDanger()) defense -= 0.7;
          }
          if (player.isTurnedOver() && !player.hasSkill('jlsg_youxia')) defense -= 0.35;

          if (player.countCards('j', 'lebu') && !player.hasSkill('yanxiao2')) defense -= 0.15;
          if (player.countCards('j', 'bingliang') && !player.hasSkill('yanxiao2')) defense -= 0.15;
          if (player.countCards('j', 'caomu') && !player.hasSkill('yanxiao2')) defense -= 0.15;

          if ((attacker.hasSkill('roulin') && player.sex == 'female') || (attacker.sex == 'female' && player.hasSkill('roulin'))) defense = defense - 2.4;

          if (!jlsg.hasBaguaEffect(player)) {
            if (player.hasSkill('jijiu')) defense -= 3;
            if (player.hasSkill('dimeng')) defense -= 2.5;
            if (player.hasSkill('guzheng') && !jlsg.getCardsNum('shan', player, attacker)) defense -= 2.5;
            if (player.hasSkill('qiaobian')) defense -= 2.4;
            if (player.hasSkill('jieyin')) defense -= 2.3;
            if (player.hasSkills('lijian|jlsg_lijian')) defense -= 2.2;
          }
          return defense;
        },
        getDefense: function(player) {
          if (player == undefined || get.itemtype(player) != 'player') {
            return 0;
          }
          var current_player = _status.event.player;
          if (!current_player) return jlsg.getValue(player);

          var defense = jlsg.getValue(player);

          if (player.get('e', '2')) defense += 2;
          if (player.get('e', '3')) defense++;
          if (player.countCards('e', 'muniu') && player.get('e', '5').cards) defense += player.get('e', '5').cards.length;

          if (jlsg.hasBaguaEffect(player)) {
            if (player.hasSkill('tiandu')) defense++;
            if (player.hasSkill('leiji')) defense += 2;
            if (player.hasSkill('boss_leiji')) defense += 2;
            if (player.hasSkill('releiji')) defense += 2;
            if (player.hasSkill('hongyan')) defense += 2;
          }
          var maixie = jlsg.ai.skill.maixie_skill.split("|");
          for (var i = 0; i < maixie.length; i++) {
            if (player.hasSkill(maixie[i]) && jlsg.isGoodHp(player)) defense++;
          }

          if (player.hasSkill('jieming')) defense += 3;
          if (player.hasSkills('yiji|jlsg_yiji')) defense += 3;
          if (player.hasSkill('guixin')) defense += game.players.length - 1;
          if (player.hasSkill('yuce')) defense += 2;
          if (player.hasSkill('chengxiang')) defense++;

          if (player.hasZhuSkill('shichou')) {
            var current = jlsg.findPlayerBySkillName('shichou_dying');
            if (current) defense += current.hp;
          }

          if (player.hasSkill('rende') && player.countCards('h') > 1 && player.hp > 2) defense++;
          if (player.hasSkill('rerende') && player.countCards('h') > 1 && player.hp > 2) defense++;
          if (player.hasSkill('kuanggu') && player.hp > 1) defense += 0.5;
          if (player.hasSkill('diykuanggu') && player.hp > 1) defense += 0.5;
          if (player.hasSkill('zaiqi') && player.hp > 1) defense = defense + ((player.maxHp - player.hp) * 0.5);
          if (player.hasSkill('tianming')) defense += 0.5;
          if (player.hasSkill('keji')) defense += player.countCards('h') * 0.25;
          if (player.hasSkill('aocai') && _status.currentPhase !== player) defense += 0.5;
          if (player.hasSkill('tianxiang')) defense += player.countCards('h') * 0.5;

          if (player.hp > jlsg.getBestHp(player)) defense += 0.8;
          if (player.hp <= 2) defense = defense - 0.4;
          if (player.hasSkill('benghuai') && player.maxHp <= 5) defense--;
          if (player.hasSkills(jlsg.ai.skill.bad_skills)) defense--;

          if (player.isZhu) {
            defense = defense - 0.4;
            if (jlsg.isZhuInDanger()) defense = defense - 0.7;
          }

          var invaliditySkill = ['yijue', 'boss_hujia', 'retieji', 'pozhou', 'jlsg_zhenhun'];
          for (var i = 0; i < invaliditySkill.length; i++) {
            if (player.disabledSkills[invaliditySkill[i]] && player.disabledSkills[invaliditySkill[i]].length > 0)
              defense -= 5;
          }

          if (player.isTurnedOver()) defense--;

          if (player.countCards('j', 'lebu') && !player.hasSkill('yanxiao2')) defense -= 0.5;
          if (player.countCards('j', 'bingliang') && !player.hasSkill('yanxiao2')) defense -= 0.5;
          if (player.countCards('j', 'caomu') && !player.hasSkill('yanxiao2')) defense -= 0.5;

          if (player.hasSkill('jijiu')) defense += 2;
          if (player.hasSkill('qingnang')) defense += 2;
          if (player.hasSkill('dimeng')) defense += 2.5;
          if (player.hasSkill('guzheng')) defense += 2.5;
          if (player.hasSkill('qiaobian')) defense += 2.4;
          if (player.hasSkill('jieyin')) defense += 2.3;
          if (player.hasSkills('jlsg_lijian|lijian')) defense += 2.1;
          if (player.hasSkill('yishe')) defense += 2;
          if (player.hasSkill('paiyi')) defense += 1.5;
          if (player.hasSkill('yongsi')) defense += 2;

          defense = defense + (game.players.length - (get.distance(player, _status.currentPhase, 'absolute')) % game.players.length) / 4;

          defense = defense + player.get('s').length * 0.25;

          return defense;
        },
        findCardInCardPile: function(name) {
          var card;
          for (var i = 0; i < ui.cardPile.childNodes.length; i++) {
            card = ui.cardPile.childNodes[i];
            if (typeof name == 'string') {
              if (card.name == name) {
                return card;
              }
            } else if (typeof name == 'function') {
              if (name(card)) {
                return card;
              }
            }
          }
          return null;
        },
        findCardInDiscardPile: function(name) {
          var cards = [];
          var card = false;
          for (var i = 0; i < ui.discardPile.childNodes.length; i++) {
            card = ui.discardPile.childNodes[i];
            if (typeof name == 'string') {
              if (card.name == name) {
                return card;
              }
            } else if (typeof name == 'function') {
              if (name(card)) {
                return card;
              }
            } else {
              cards = cards.concat(card);
            }
          }
          if (cards.length) return cards.randomGet();
          return null;
        },
        isZhuHealthy: function() {
          var zhu = get.zhu();
          if (!zhu) return false;
          var zhu_hp;
          if (zhu.hasSkill('benghuai') && zhu.hp > 4) {
            zhu_hp = 4;
          } else {
            zhu_hp = zhu.hp;
          }
          return zhu_hp > 3 || (zhu_hp > 2 && jlsg.getDefense(zhu) > 3);
        },
        isZhuInDanger: function() {
          var zhu = get.zhu();
          if (!zhu) return false;
          var zhu_hp;
          if (zhu.hasSkill('benghuai') && zhu.hp > 4) {
            zhu_hp = 4;
          } else {
            zhu_hp = zhu.hp;
          }
          return zhu_hp < 3;
        },
        findPlayerBySkillName: function(skills) {
          return game.findPlayer(function(player) {
            return player.hasSkills(skills);
          });
        },
        isFriend: function(other, another) {
          return get.attitude(other, another) > 0;
        },
        isEnemy: function(other, another) {
          return get.attitude(other, another) < 0;
        },
        getFriends: function(player) {
          return game.filterPlayer(function(target) {
            return jlsg.isFriend(player, target);
          });
        },
        getFriendsNoself: function(player) {
          return game.filterPlayer(function(target) {
            return jlsg.isFriend(player, target) && player != target;
          });
        },
        getEnemies: function(player) {
          return game.filterPlayer(function(target) {
            return jlsg.isEnemy(player, target);
          });
        },
        filterFriend: function(player, func) {
          var friends = jlsg.getFriends(player);
          for (var i = 0; i < friends.length; i++) {
            if (func(friends[i])) {
              return game.players[i];
            }
          }
          return null;
        },
        filterFriends: function(player, func) {
          var list = [];
          var friends = jlsg.getFriends(player);
          for (var i = 0; i < friends.length; i++) {
            if (func(friends[i])) {
              list.push(game.players[i]);
            }
          }
          return list;
        },
        filterEnemy: function(player, func) {
          var enemies = jlsg.getEnemies(player);
          for (var i = 0; i < enemies.length; i++) {
            if (func(enemies[i])) {
              return game.players[i];
            }
          }
          return null;
        },
        filterEnemies: function(player, func) {
          var list = [];
          var enemies = jlsg.getEnemies(player);
          for (var i = 0; i < enemies.length; i++) {
            if (func(enemies[i])) {
              list.push(game.players[i]);
            }
          }
          return list;
        },
        countFriends: function(player) {
          return game.countPlayer(function(target) {
            return jlsg.isFriend(player, target) && target != player;
          });
        },
        countEnemies: function(player) {
          return game.countPlayer(function(target) {
            return jlsg.isEnemy(player, target);
          });
        },
        countNextEmenies: function(from, to) {
          var num = 0;
          var current = from.getNext();
          for (var i = 0; i < 10 && current != to; i++) {
            if (jlsg.isEnemy(to, current)) {
              num++;
            }
            current = current.getNext();
          }
          return num;
        },
        getNextEmenies: function(from, to) {
          var list = [];
          var current = from.getNext();
          for (var i = 0; i < 10 && current != to; i++) {
            if (jlsg.isEnemy(to, current)) {
              list.push(current);
            }
            current = current.getNext();
          }
          return list;
        },
        countCanShaMe: function(player) {
          return game.countPlayer(function(target) {
            return jlsg.isEnemy(player, target) && target.canUse('sha', player) && get.effect(target, {
              name: 'sha'
            }, player) > 0;
          });
        },
        getCanShaMe: function(player) {
          return game.filterPlayer(function(target) {
            return jlsg.isEnemy(player, target) && target.canUse('sha', player) && get.effect(player, {
              name: 'sha'
            }, target) > 0;
          });
        },
        getWillShaTarget: function(player) {
          var target = game.filterPlayer(function(target1) {
            return player.canUse('sha', target1) && get.effect(target1, {
              name: 'sha'
            }, player) > 0;
          });
          target.sort(function(a, b) {
            return get.effect(a, {
              name: 'sha'
            }, player) < get.effect(a, {
              name: 'sha'
            }, player);
          });
          return target[0];
        },
        getCardsNum: function(class_name, player, from) {
          if (player == undefined || get.itemtype(player) != 'player') player = _status.event.player;
          var cards = player.get('h');
          if (player.countCards('e', 'muniu') && player.get('e', '5').cards && player.get('e', '5').cards.length) {
            cards = cards.concat(player.get('e', '5').cards);
          }
          var num = 0,
            shownum = 0,
            redtao = 0,
            redsha = 0,
            rencard = 0,
            blackcard = 0,
            blackwuxie = 0,
            equipwuxie = 0;
          var equipcard = 0,
            heartsha = 0,
            hearttao = 0,
            spadewuxie = 0,
            spadejiu = 0,
            spadecard = 0,
            diamondcard = 0;
          var clubcard = 0,
            shashan = 0,
            jiunum = 0;
          var forbid = false;
          if (!from && _status.event.player != player) forbid = true;
          from = from || _status.event.player;
          for (var i = 0; i < cards.length; i++) {
            var card = cards[i];
            if (!forbid && player == from) {
              shownum++;
              if (card.name == class_name) num++;
              if (card.name == 'jiu') jiunum++;
              if (get.type(card) == 'equip') equipcard++;
              if (card.name == 'sha' || card.name == 'shan') shashan++;
              if (get.color(card) == 'red') {
                rencard++;
                if (card.name != 'sha') redsha++;
                if (card.name != 'tao') redtao++;
              }
              if (get.color(card) == 'black') {
                blackcard++;
                if (card.name != 'wuxie') blackwuxie++;
              }
              if (get.suit(card) == 'heart') {
                if (card.name != 'sha') heartsha++;
                if (card.name != 'tao') redtao++;
              }
              if (get.suit(card) == 'spade') {
                if (card.name != 'wuxie') spadewuxie++;
                if (card.name != 'jiu') spadejiu++;
              }
              if (get.suit(card) == 'diamond' && card.name != 'sha') diamondcard++;
              if (get.suit(card) == 'club') clubcard++;
            }
          }
          var ecards = player.get('e');
          for (var i = 0; i < ecards.length; i++) {
            var card = ecards[i];
            equipcard++;
            if (player.countCards('h') > player.hp) equipwuxie++;
            if (get.color(card) == 'red') {
              redtao++;
              redsha++;
            }
            if (get.suit(card) == 'heart') hearttao++;
            if (get.suit(card) == 'spade') spadecard++;
            if (get.suit(card) == 'diamond') diamondcard++;
            if (get.suit(card) == 'club') clubcard++;
          }
          if (class_name == 'sha') {
            var shanum;
            if (player.hasSkill('wusheng')) {
              shanum = redsha + num + (player.countCards('h') - shownum) * 0.69;
            }
            if (player.hasSkill('shizhi') && player.hp == 1) {
              shanum = shashan + (player.countCards('h') - shownum) * 0.3;
            } else if (player.hasSkill('wushen')) {
              shanum = heartsha + num + (player.countCards('h') - shownum) * 0.5;
            } else if (player.hasSkill('jinjiu')) {
              shanum = jiunum + num + (player.countCards('h') - shownum) * 0.5;
            } else if (player.hasSkills('longhun|jlsg_longhun')) {
              shanum = diamondcard + num + (player.countCards('h') - shownum) * 0.5;
            } else if (player.hasSkill('nos_gongji')) {
              shanum = equipcard + num + (player.countCards('h') - shownum) * 0.5;
            } else if (player.hasSkills('longdan|chixin')) {
              shanum = shashan + (player.countCards('h') - shownum) * 0.72;
            } else if (player.countCards('e', 'zhangba')) {
              shanum = num + (player.countCards('h') - shownum) * 0.2;
            } else {
              shanum = num + (player.countCards('h') - shownum) * 0.35;
            }
            return (jlsg.hasWushuangEffect(player) && shanum * 2) || shanum;
          } else if (class_name == 'shan') {
            if (player.hasSkill('qingguo')) {
              return blackcard + num + (player.countCards('h') - shownum) * 0.8;
            } else if (player.hasSkills('longdan|chixin')) {
              return shashan + (player.countCards('h') - shownum) * 0.72;
            } else if (player.hasSkills('longhun|jlsg_longhun')) {
              return clubcard + num + (player.countCards('h') - shownum) * 0.65;
            } else if (player.hasSkill('jieyue3')) {
              return rencard + num + (player.countCards('h') - shownum) * 0.5;
            } else {
              return num + (player.countCards('h') - shownum) * 0.6;
            }
          } else if (class_name == 'tao') {
            if (player.hasSkill('jijiu')) {
              return num + redtao + (player.countCards('h') - shownum) * 0.6;
            } else if (player.hasSkills('longhun|jlsg_longhun')) {
              return hearttao + num + (player.countCards('h') - shownum) * 0.5;
            } else {
              return num;
            }
          } else if (class_name == 'jiu') {
            if (player.hasSkill('jiuchi')) {
              return num + spadejiu + (player.countCards('h') - shownum) * 0.3;
            } else if (player.hasSkill('jiushi')) {
              return num + 1;
            } else {
              return num;
            }
          } else if (class_name == 'wuxie') {
            if (player.hasSkill('kanpo')) {
              return num + blackwuxie + (player.countCards('h') - shownum) * 0.5;
            } else if (player.hasSkill('yanzheng')) {
              return num + equipwuxie;
            } else if (player.hasSkill('ruzong')) {
              return num * 3;
            } else {
              return num;
            }
          } else {
            return num;
          }
        },
        getCards: function(name, player) {
          player = player || _status.event.player;
          return player.countCards('he', name);
        },
      };
      lib.jlsg = jlsg;
      window.jlsg = jlsg;
      console.timeEnd(_status.extension + 'pre');
    },

    package: {
      character: {
        character: {},
        translate: {},
      },
      card: {
        card: {},
        translate: {},
        list: [],
      },
      skill: {
        skill: {},
        translate: {},
      },
      intro: "三国杀DIY吧精品，包括历届吧赛等。部分武将为戒除联盟编写。作者联系QQ：691127429，交流QQ群：533488054",
      author: "陈恭杜弼的区别",
      diskURL: "",
      forumURL: "",
    },
    files: {
      "character": [],
      "card": [],
      "skill": []
    }
  }
})